Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Rails Cors
1. install rack-cors gem (
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.