Disable CORS logging by default in development (#6592)

* Disable CORS logging by default in development

* Fix typos
This commit is contained in:
rhymes 2020-03-11 20:30:18 +01:00 committed by GitHub
parent 5253ccaa75
commit 13ebedbc6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -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 `*`

View file

@ -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
```