I have never had success in sending a POST request from a different domain to my https://*.netlify.com/.netlify/functions/post-route
. I have allowed the headers as below, but still no luck.
const headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE'
};
return {
statusCode: 200,
headers,
body: JSON.stringify({message:'Successfully updated the post!'})
}
However, if I run at Local with
netlify-cli
, it works fine. e.gtest-domain.test
tolocalhost:8888/.netlify/functions/post-route
(netlify functions)
Does Netlify prevent post/put/delete requests from different domain?