- Use rack-cors
- Add it to middleware
- Adjust permissions if you want
- May the force be with you
Created
October 5, 2012 07:56
-
-
Save dmitriy-kiriyenko/3838649 to your computer and use it in GitHub Desktop.
Solve of cross-domain ajax requests
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
# Add it to config/application.rb | |
module YourApplicationName | |
class Application < Rails::Application | |
config.middleware.use Rack::Cors do | |
# Allow everything to everyone | |
# Instead in block `allow` you can use constraints | |
# to achieve some security. | |
# More on this options here: https://github.com/cyu/rack-cors | |
allow do | |
origins '*' | |
resource '*', | |
:methods => [:get, :post, :put, :delete, :options], | |
:headers => :any | |
end | |
end | |
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
# Add it to Gemfile | |
gem 'rack-cors', :require => 'rack/cors' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment