【发布时间】:2021-10-25 11:39:38
【问题描述】:
我创建了一个简单的 HTTP Trigger 函数并将其链接到 API 管理。
然后我在 API 管理 中设置了 Cors 政策,如下所示:
<policies>
<inbound>
<cors>
<allowed-origins>
<origin>*</origin>
</allowed-origins>
<allowed-methods>
<method>*</method>
</allowed-methods>
</cors>
</inbound>
<backend>
<forward-request />
</backend>
<outbound />
<on-error />
当我从 blazor wasm 调用它时,它会给出以下错误:
Access to fetch at 'https://example-api.azure-api.net/teste/Teste' from origin 'https://localhost:5001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
需要注意的几点:
- 当我直接从浏览器调用“https://example-api/teste/Teste”时,它可以工作。
- 当我直接从 blazor wasm 调用函数时(没有 API 管理),它可以工作。
- 当我从 blazor wasm 调用“https://example-api/teste/Teste”时,它给出了提到的 Cors 错误。
有什么想法吗?
【问题讨论】:
标签: azure azure-functions azure-api-management