Skip to content

Instantly share code, notes, and snippets.

@kagemusha
Created January 26, 2014 00:54
Show Gist options
  • Save kagemusha/8626265 to your computer and use it in GitHub Desktop.
Save kagemusha/8626265 to your computer and use it in GitHub Desktop.
Rails Cors
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