From 13ebedbc6d5400aa003295ad18190d19e05be377 Mon Sep 17 00:00:00 2001 From: rhymes Date: Wed, 11 Mar 2020 20:30:18 +0100 Subject: [PATCH] Disable CORS logging by default in development (#6592) * Disable CORS logging by default in development * Fix typos --- config/application.rb | 3 ++- docs/troubleshooting.md | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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 +```