From e2d9bd65eb90e502f55a817a10e92c137b3605aa Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Thu, 22 May 2025 09:16:43 +0530 Subject: [PATCH] chore: enable CORS for APIs --- config/initializers/cors.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 1d516370f..d27fe0321 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -14,6 +14,11 @@ Rails.application.config.middleware.insert_before 0, Rack::Cors do if ActiveModel::Type::Boolean.new.cast(ENV.fetch('CW_API_ONLY_SERVER', false)) || Rails.env.development? resource '*', headers: :any, methods: :any, expose: %w[access-token client uid expiry] end + + # This is temporary fix for the issue the loading APIs from the frontend, we will remove this once we have a proper solution + if ActiveModel::Type::Boolean.new.cast(ENV.fetch('ENABLE_API_CORS', false)) + resource '/api/*', headers: :any, methods: :any, expose: %w[access-token client uid expiry] + end end end