I have a API endpoint i.e. http://api.example.com/contact and it is working when I tried to use the POST method but when I configured the SSL certificate with this then the URL is changed https://api.example.com/contact but method POST is not working. I have tried with the bellow code
let response = await fetch(ApiUrlConstant.getApiFullUrl("web.contact"), {
method: "POST",
headers: {
"Access-Control-Allow-Origin" : "https://api.example.com/",
"Content-Type": "application/json;charset=utf-8",
"Access-Control-Allow-Credentials": "true",
"method": "POST",
},
body: JSON.stringify(details),
});
setStatus("Submit");
let result = await response.json();
alert(result.status);
};
Whenever I tried method POST then I got this error
www.example.com/:1 Access to fetch at 'https://api.example.com/contact' from origin 'https://www.example.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
I have gone through the article and discussion on StackOverflow but in my case, It's not working. Now it's hard to understand which one is correct or where I did wrong?