Created
January 26, 2014 00:54
-
-
Save kagemusha/8626265 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
1. install rack-cors gem (https://github.com/cyu/rack-cors) | |
gem 'rack-cors', :require => 'rack/cors' | |
2. add to application.rb | |
config.middleware.insert_before "Rack::Lock", "Rack::Cors", :debug => true, :logger => Rails.logger do | |
allow do | |
origins '*' | |
resource '/cors', | |
:headers => :any, | |
:methods => [:post], | |
:credentials => true, | |
:max_age => 0 | |
resource '*', | |
:headers => :any, | |
:methods => [:get, :post, :delete, :put, :options], | |
:max_age => 0 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment