-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support cors via rails not nginx. #622
- Loading branch information
Martin Fenner
committed
Sep 9, 2020
1 parent
2ff7784
commit d4ae801
Showing
6 changed files
with
27 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
# Be sure to restart your server when you modify this file. | ||
|
||
# Avoid CORS issues when API is called from the frontend app. | ||
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. | ||
|
||
# Read more: https://github.com/cyu/rack-cors | ||
|
||
Rails.application.config.middleware.insert_before 0, Rack::Cors, debug: true, logger: (-> { Rails.logger }) do | ||
allow do | ||
origins '*' | ||
|
||
resource '*', | ||
headers: :any, | ||
expose: ["Authorization", "X-Credential-Username", "X-Anonymous-Consumer"], | ||
methods: [:get, :post, :put, :patch, :delete, :options, :head] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters