I realize this question is asked here at nauseum but I'm unable to find a solution to something that seems so common.
Server app is showing the following response when trying to make a post request:
Access-Control-Allow-Headers x-requested-with, Content-Type…accept, client-security-token
Access-Control-Allow-Methods POST, GET, OPTIONS, DELETE, PUT
Access-Control-Allow-Origin *
Access-Control-Max-Age 1000
but getting error:
> Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3000/contact. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
I'm trying to make the request using JS fetch function:
fetch('//<my-app-server.com/endpoint>', {
method: 'post',
body: send_data,
mode: 'cors',
headers: {
'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
},
}).then((result) => {
console.log('success')
}).catch((error) =>{
console.log(error);
})
I've tried with and without the headers. Using a managed apache host and just want to open up global CORS requests. Not sure what I'm missing here.
Any advice would be welcome.