I have the following request in my client code:
$.ajax({
type: "GET",
url: "some_external_address.php",
headers: {
Authorization: "Bearer " +localStorage.getItem("token")
},
success: function (data) {
// some code
},
error: function (data) {}
});
And the following server code:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header("Access-Control-Allow-Headers: Authorization, X-Requested-With, Content-Type, Accept, Origin");
header('Access-Control-Allow-Credentials: true');
header("HTTP/1.0 404 Not Found");
The problem is that when I send my request without the Authorization header it works well.
But when I need to send an error response with an error code other than 2XX it gives this error:
It does not have HTTP ok status.