Skip to content

Instantly share code, notes, and snippets.

@chrsgrffth
Last active June 1, 2016 19:45
Show Gist options
  • Save chrsgrffth/34ddbff061e134aec7e0b0393bddc0cc to your computer and use it in GitHub Desktop.
Save chrsgrffth/34ddbff061e134aec7e0b0393bddc0cc to your computer and use it in GitHub Desktop.
Allow Client to Communicate with Rails API (Allow-Access-Control-Origin)
# CORS config
config.middleware.insert_before 0, 'Rack::Cors' do
allow do
origins 'localhost:3000', 'localhost:3001'
resource '*', headers: :any, methods: [:get, :post, :options]
end
end
# Rack Cors.
gem 'rack-cors', :require => 'rack/cors'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment