diff --git a/config/application.rb b/config/application.rb index bb110fa5d..ea5860dd2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -61,7 +61,8 @@ module PracticalDeveloper # Enable CORS for API v0 # (logging is only activated when debug is enabled) - config.middleware.insert_before 0, Rack::Cors, debug: Rails.env.development?, logger: (-> { Rails.logger }) do + debug_cors = ENV["DEBUG_CORS"].present? ? true : false + config.middleware.insert_before 0, Rack::Cors, debug: debug_cors, logger: (-> { Rails.logger }) do allow do origins do |source, _env| source # echo back the client's `Origin` header instead of using `*` diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 3f5875ddc..201a958b2 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -80,3 +80,12 @@ end If instead you want to tune the Elasticsearch disk allocator's settings, please refer to [Disk-based shard allocation](https://www.elastic.co/guide/en/elasticsearch/reference/current/disk-allocator.html#disk-allocator). + +## CORS + +If you are experiencing CORS issues locally or need to display more information +about the CORS headers, add the following variable to your `application.yml`: + +```yml +DEBUG_CORS: true +```