The issue you are facing is due to the fact that Azure Functions built-in CORS support does not handle preflight requests when custom headers are used. Preflight requests are made by browsers as a security measure to ensure that the server will accept the actual request.
You need to configure your Azure Function App to explicitly allow the custom headers you are using
Here’s a workaround for this issue:1. Disable the Azure Functions built-in CORS support.
- Implement CORS manually in your Azure Function code Here’s a sample code snippet
If this answers your query, do click// Fetching the name from the path parameter in the request URL var response = req.CreateResponse(HttpStatusCode.OK, "Hello World!"); // Define the headers response.Headers.Add("Access-Control-Allow-Origin", "*"); // update this to your actual origin response.Headers.Add("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE"); response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Your-Custom-Header"); return response;
Accept Answer
andYes
for this answer helpful.