Azure APIM 在 API Post 方法上出现 CORS 错误

Azure APIM getting CORS error on API Post method

我试图在我的 Web 应用程序中使用 POST API 并收到错误消息: CORS 策略已阻止从来源 'http://localhost:3030' 访问位于 'https://XXXXX' 的 XMLHttpRequest:对预检请求的响应未通过访问控制检查:没有 'Access-Control-Allow-Origin' header 出现在请求的资源。

下面是 APIM 在 API 级别的 CORS 设置:

<policies>
<inbound>
    <base />
    <cors allow-credentials="true">
        <allowed-origins>
            <origin>http://localhost:3030/</origin>
            
        </allowed-origins>
        <allowed-methods preflight-result-max-age="300">
            <method>GET</method>
            <method>POST</method>
            <method>OPTIONS</method>
        </allowed-methods>
        <allowed-headers>
            <header>*</header>
        </allowed-headers>
    </cors>
</inbound>
<backend>
    <base />
</backend>
<outbound>
    <base />
</outbound>
<on-error>
    <base />
</on-error>

我不确定这里的设置有什么问题。快速帮助将不胜感激!!

提前致谢。

您应该在 Azure app servicesAPIM 中配置 CROS。

从你的api设置来看,应该没有问题。请检查您的网络应用程序中的跨域设置。

更多详细信息,您可以参考以下帖子来定位您的问题。

2. Getting Access Control Allow Origin Error While Accessing Web Api hosted in AZURE RRS feed