Hi
I setup a Function that sends a email. I call this function from my Vue client that is hosted somewhere else then Netlify, or more correctly at this stage it’s localhost. So to the problem I have is preflight CORS error.
Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
So it works with Postman as that cruises by the CORS but it’s totally impossible to get this to work from a webpage.
My header declaration looks like this with the preflight and headers, what am I doing wrong? Let me know if you need anything from me like account number ect.
const headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Allow-Methods": "POST, OPTIONS",
}
if (event.httpMethod === 'OPTIONS') {
console.log('options: preflight test CORS')
return {
statusCode: '204',
headers
}
}