Azure App Service (Node) CORS origins won't work no matter where I add them

南笙酒味 提交于 2020-01-15 07:21:07

问题


The Azure CORS settings doesn't seem to work at all unless I specify * any and all requests will return

"has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status."

I've added my CORS http + https variants of both my production + dev environment frontend. I have also added them in the web.config.

<add name="Access-Control-Allow-Origin" value="https://LINK"/>
<add name="Access-Control-Allow-Origin" value="https://LINK/"/>

It is becoming extremely unpredictable and unreliable. The application is configured to allow all origins:

app.options('/', function(req, res) {
  res.setHeader('Access-Control-Allow-Origin', '*');
  res.setHeader('Access-Control-Allow-Methods', '*');
  res.setHeader('Access-Control-Allow-Headers', '*');
  res.end();
});

So it would send preflight data. Does azure CORS not send any preflight data? Am I better off just setting * everywhere and then managing things via the API myself? Will Azure not overwrite that configuration anyway? Am I stuck with no way of managing CORS?


回答1:


Yes, definitely you can achieve it either by setting CORS headers from the Azure portal or by adding CORS headers from your App.

Here's how you can set it form azure portal.

  1. Navigate to azure portal
  2. Navigate to the app service you have created.
  3. Click on CORS in the app.
  4. Enter URL's in the empty Allowed Origins text box.
  5. Click Save.



来源:https://stackoverflow.com/questions/55591856/azure-app-service-node-cors-origins-wont-work-no-matter-where-i-add-them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!