How to send CORS headers with Devise if user not authorized (401 response)

后端 未结 2 1300
栀梦
栀梦 2020-12-28 17:36

I am working on an app, where server and the api-consuming client reside under different domains, so I would like to use CORS. To do so, I have to set corresponding http hea

2条回答
  •  半阙折子戏
    2020-12-28 17:55

    I successfully used the rack-cors gem https://github.com/cyu/rack-cors and outlined my experience on my blog.

    Punchline: Specify middleware order so cors handler is before warden:

    config.middleware.insert_before Warden::Manager, Rack::Cors
    

提交回复
热议问题