Skip to content

Instantly share code, notes, and snippets.

@dpaluy
Created August 26, 2015 00:14
Show Gist options
  • Select an option

  • Save dpaluy/d76d52d59ac3619fcc97 to your computer and use it in GitHub Desktop.

Select an option

Save dpaluy/d76d52d59ac3619fcc97 to your computer and use it in GitHub Desktop.
Solving CORS with rack-cors gem
class Application < Rails::Application
# ...
config.middleware.insert_before Warden::Manager, Rack::Cors do
allow do
origins %r{^https?:\/\/[a-z0-9\-]+.yourdomain.com:?\d*$}i
resource '*',
headers: :any,
methods: [:get, :post, :put, :create, :delete, :options]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment