本文介绍了无论我在何处添加Azure App Service(节点)CORS来源均不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure CORS设置似乎根本不起作用,除非我指定*任何,所有请求都将返回

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."

我添加了我的生产环境和开发环境前端的CORS http + https变体。我也在web.config中添加了它们。

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();
});

因此它将发送飞行前数据。天蓝色CORS不会发送任何飞行前数据吗?我最好只在任何地方设置*,然后自己通过API管理事情吗? Azure是否仍将不覆盖该配置?我是否无法管理CORS?

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?

推荐答案

是的,绝对可以通过在Azure中设置CORS标头来实现门户或通过从您的应用程序添加CORS标头。

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. 导航到Azure门户

  2. 导航到您创建的应用程序服务。

  3. 在应用程序中单击CORS。

  4. 在空白的允许的来源文本框中输入URL。

  5. 单击保存。

  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.

这篇关于无论我在何处添加Azure App Service(节点)CORS来源均不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 07:12