I have an Azure Functions App that I've deployed on IIS on a VM (don't ask why, I'll start crying).
Anyway, the functions are working perfectly fine, I checked with Postman. Now when I try to call the HttpTrigger functions through my Blazor App, I get a CORS error Preflight MissingAllowedOriginHeader
.
On localhost, I was using CORS: "*"
in local.settings.json and it was working fine. But on deployment it is not working.
Here's what I've tried so far:
- Adding
CORS: "*"
in host.json - Adding the following in web.config:
<cors enabled="true">
<add origin="*" />
</cors>
- Adding custom header called
Access-Control-Allow-Origin
in Http Response Headers in IIS - Copying `local.settings.json` to output and including it in published files
- Adding the following in web.config
<httpProtocol>
<customHeaders>
<clear />
<add name="X-Powered-By" value="ASP.NET" />
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
</httpProtocol>
But after each of those, the only thing that changes, is the error becomes PreflightInvalidStatus
For the life of me, I cannot figure out how to get it working.
Any help would be appreciated.
Much thanks