码迷,mamicode.com
首页 > Web开发 > 详细

rails 网站跨域

时间:2015-09-16 18:01:17      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

 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

rails 网站跨域

标签:

原文地址:http://www.cnblogs.com/messipapa/p/4813687.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!