I’m getting CORS Preflight error and it says that No 'Access-Control-Allow-Origin' header is present on the requested resource.
. The problem is that it’s actually there, I had the same problem with my GET request, added the headers and everything works, but for POST request it still returns the CORS error.
Here’s my handler and headers
const headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
};
exports.handler = async function (event, context) {
ip = event.headers['client-ip'];
const request = JSON.parse(event.body);
const respond = await authenticate((auth) =>
addEvent(auth, request.name, request.dateTime, request.email, request.info)
);
return {
statusCode: respond.status,
body: JSON.stringify(respond),
headers,
};
};