My netlify function has these headers set up:
const headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Access-Control-Allow-Headers, Content-Type, Authorization',
'Access-Control-Allow-Methods': '*',
"Content-Type": "application/json"
};
return {
statusCode: 200,
headers: headers,
}
TOML file
[build]
functions = "functions"
[[headers]]
# Define which paths this specific [[headers]] block will cover.
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "*"
Access-Control-Allow-Headers = "Content-Type, Authorization"
Access-Control-Allow-Methods = "GET, POST, PUT, DELETE,OPTIONS"
Content-Type= "application/json"
But I still get this goddamn error:
Access to XMLHttpRequest at 'https://XXXX' from origin 'https://XXX' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
How hard it should be to configure CORS…
P.S. I’m sending a JSON request