您的位置:首页 > 运维架构 > 网站架构

rails 网站跨域

2015-09-16 16:28 447 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: