CORS - Cross-Domain AJAX Without JSONP By Allowing Origin On Server

后端 未结 3 1897
无人共我
无人共我 2020-11-30 13:13

I have two separate apps on the same server, with the EmberJS one trying to do cross-domain calls to my backend API.

I set up my backend API to allow cross-domain re

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 13:16

    You can use rack-cors in Rails 5, to set it to allow all URLs.

    Rails.application.config.middleware.insert_before 0, Rack::Cors do
      allow do
        origins '*'
        resource '*', headers: :any, methods: [
          :get, :post, :put, :patch, :delete, :options, :head
        ]
      end
    end
    

提交回复
热议问题