Instantly share code, notes, and snippets.

@benmacleod /Gemfile
Last active Aug 29, 2015

Embed
What would you like to do?
Adding CORS support to a Ruby on Rails app working with a Squawkbox editor session
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
module MyApp
class Application < Rails::Application
# etc., etc.
config.middleware.insert_after Rails::Rack::Logger, Rack::Cors, logger: Rails.logger do
allow do
origins 'localhost:3000', '127.0.0.1:3000', /(app|staging|dev).mysquawkbox.com/
resource '*', headers: :any, :methods => [:put, :post, :get, :options]
end
end
end
end
source 'https://rubygems.org'
gem 'rails'
# etc, etc.
gem 'rack-cors', require: 'rack/cors'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment