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
时间: 2024-11-24 05:16:22