I've created a simple HTTP Trigger function and linked it to the API management.
Then I've set the Cors policy in the API Management like this:
<policies>
<inbound>
<cors>
<allowed-origins>
<origin>*</origin>
</allowed-origins>
<allowed-methods>
<method>*</method>
</allowed-methods>
</cors>
</inbound>
<backend>
<forward-request />
</backend>
<outbound />
<on-error />
When I call it from a blazor wasm, it gives the following error:
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.
A few points to notice:
- When I call 'https://example-api/teste/Teste' directly from the browser, it works.
- When I call the function from blazor wasm directly (without API management) it works.
- When I call 'https://example-api/teste/Teste' from blazor wasm it gives the Cors Error mentioned.
Any ideias?