7
down vote
accepted
gem install rack-cors
Or in your Gemfile:
gem 'rack-cors', :require => 'rack/cors'
修改 config.ru
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