add to your Gemfile:
gem 'rack-cors'
Add below code to config/application.rb
# Rails 3/4
config.middleware.insert_before 0, "Rack::Cors" do
allow do
origins '*'
resource '*', :headers => :any, :methods => :any
end
end
Rails项目,支持angular时,做allow Domain 的设置
参考: http://stackoverflow.com/questions/29751115/how-to-enable-cors-in-rails-4-app
This post is licensed under
CC BY 4.0
by the author.