Is it possible to get the error code of a failed preflight request so that I can print a meaningful error message? (Or is there a habit of printing a static error for all failed preflight requests no matter the code?)
Clearly, the status code 401
is printed to the console, but the error handler or a .catch()
statement only receive the error object thrown.
If I remove the header that triggers the preflight, I get to handle the response myself and I can extract the status code.
No, it isn't.
If the status code of the preflight response is not 200, then the Same Origin Policy will prevent any information about the response from being extracted from it.
I've just finished setting up a web API to always return 200 OK status for OPTIONS requests for this reason.