OWIN token authentication 400 Bad Request on OPTIONS from browser

后端 未结 5 505
眼角桃花
眼角桃花 2021-02-05 16:22

I am using token authentication for small project based on this article: http://bitoftech.net/2014/06/09/angularjs-token-authentication-using-asp-net-web-api-2-owin-asp-net-iden

5条回答
  •  爱一瞬间的悲伤
    2021-02-05 16:50

    Are you running it locally or are you publishing it to Azure like in the blog article's sample code?

    If you're running it on Azure, you can easily fix CORS problems by enabling CORS in the Azure portal:

    1. Click on your App Service in the Azure Portal to enter the management screen.
    2. In the list of management options, scroll down to the 'API' section, where you will find the 'CORS' option. (Alternatively type 'CORS' in the search box).
    3. Enter the allowed origin, or enter '*' to enable all, and click save.

    This fixed the OPTIONS preflight check problem for me, which a few other people seem to have had from the code in that particular blog article.

提交回复
热议问题