I am trying to use Rack::Cors with my Rails 4 application so that I can do a JSON based API.
CORS is in my Gemfile like this:
gem \'rack-cors\', :req
I ran into the same problem with heroku. I found this blog with the same rack-cors issue.
Just moved the use Rack::Cors to config.ru, redeployed to heroku and it works.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
require 'rack/cors'
use Rack::Cors do
# allow all origins in development
allow do
origins '*'
resource '*',
:headers => :any,
:methods => [:get, :post, :delete, :put, :options]
end
end