Created
March 18, 2020 03:49
-
-
Save hendra/7689eefa97911b0ac996c6f233327922 to your computer and use it in GitHub Desktop.
rails cors
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
# 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 do | |
allow do | |
origins '*' | |
resource( | |
'/api/*', | |
headers: %w(Authorization), | |
methods: :any, | |
expose: ["Authorization"], | |
max_age: 600 | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment