Skip to content

Instantly share code, notes, and snippets.

@linyiru
Created November 19, 2018 11:48
Show Gist options
  • Save linyiru/563d5e37c0855e348999dcf4f658f6f9 to your computer and use it in GitHub Desktop.
Save linyiru/563d5e37c0855e348999dcf4f658f6f9 to your computer and use it in GitHub Desktop.
CORS initializer on Rails
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins ENV.fetch('ALLOWED_ORIGINS') { '*' }
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment