Skip to content

Instantly share code, notes, and snippets.

@benmacleod
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmacleod/83f3be0e88e91301304c to your computer and use it in GitHub Desktop.
Save benmacleod/83f3be0e88e91301304c to your computer and use it in GitHub Desktop.
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