Is there a way to simply check if an endpoint exists while ignoring the cors error thrown?
I'm testing urls that would either be http or https, to figure out what they are i want to test the https url first and then the http url. The problem during this however is that the responses always returns a cors error. The fact that i get cors errors shouldn't be a problem though because in my error logs i can see the corresponding statuscode 404
for not found and 200
for success.
This is exactly the information I need but I don't know how to access it in JS. I tried using Axios and fetch but haven't found a solution yet. Does anyone have any suggestions?
To be clear i don't have any problems finding the statuscode in any other requests, it's only handling these CORS errors giving a problem.
suggestions such as the one below don't fix my error.
fetch(`${baseUrl}api/user/login`, {
credentials: "include", // ¹ See note below
headers: myHeaders
})
.then(function(response) {
console.log(response.status); // Will show you the status
if (!response.ok) {
throw new Error("HTTP status " + response.status);
}
return response.json();
})
.then(// ...