Web Api 2 Preflight CORS request for Bearer Token

后端 未结 4 1197
天命终不由人
天命终不由人 2020-12-28 17:19

I have a web-app with an AngularJS front-end and a Web Api 2 back-end, and it uses bearer-tokens for authentication.

All is well in FireFox & IE, but with Chrome

4条回答
  •  北海茫月
    2020-12-28 17:51

    Let me add one thing I have learned today. This sample:

    app.UseCors(CorsOptions.AllowAll);
    

    worked for me since the beginning. I just wasn't aware, becuase the requests I have been doing to verify, did not have following headers:

    Origin: http://hostname
    Access-Control-Request-Method: GET
    

    Only after I added those, the correct headers started to appear in responses.

提交回复
热议问题