Last active
August 29, 2015 14:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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