[英]NodeJS + Express with Angular on Localhost: Blocked by CORS preflight
[英]LocalHost CORS failing in Preflight for Azure APIM
尝试从本地主机与我的 Azure APIM 端点通信时,出现 CORS 预检失败。 我已经修改了 APIM 和 .Net Core API 本身的政策,但我仍然没有运气。 以下是我的政策在 APIM 中的“所有操作”部分的外观。 如果有帮助的话,前端是一个角度应用程序。 在 GET 上,我还在标题中附加了 ocp-apim-subscription-key。
<cors>
<allowed-origins>
<origin>*</origin>
</allowed-origins>
<allowed-methods preflight-result-max-age="300">
<method>*</method>
</allowed-methods>
<allowed-headers>
<header>*</header>
</allowed-headers>
<expose-headers>
<header>*</header>
</expose-headers>
</cors>
Azure app services
和APIM
配置 CORS。Seckey
。 <system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
**请参考下面的文档了解更多详情**
在与我公司的 Devops 团队和 IT 管理人员合作后,我能够解决它。 显然,我公司的计算机需要在我们的 Windows HOST 文件中从 azure 获取服务器 APIMs IP 的工作域。 一旦我添加了这一点,我就没有问题并且政策能够起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.