Rails Responds with 404 on CORS Preflight Options Request

前端 未结 7 1284
既然无缘
既然无缘 2020-12-10 00:42

I\'m creating a set of services using Rails 4, which I am consuming with a JavaScript browser application. Cross-origin GETS are working fine, but my POSTs are failing the p

相关标签:
7条回答
  • 2020-12-10 01:15

    I ran into the same issue, and am currently evaluating the following routes for any possible security / performance issues. They solve the issue, but...

    match '/', via: [:options], 
     to:  lambda {|env| [200, {'Content-Type' => 'text/plain'}, ["OK\n"]]}
    match '*unmatched', via: [:options],  
     to:  lambda {|env| [200, {'Content-Type' => 'text/plain'}, ["OK\n"]]}
    

    Despite 'match' supposedly not working in Rails 4, apparently it does work if you restrict it to a specific method.

    0 讨论(0)
提交回复
热议问题