You are making a cross origin request from XMLHttpRequest.
In a simple case, this means that the server has to grant permissions to the JavaScript before the browser will give the data to the JavaScript.
This is not a simple case. You are making a complex request which requires preflight authorisation.
Before making the POST request you want to make, the browser is making an OPTIONS request asking for permission.
The server is responding to the OPTIONS request with a 401 response. The error message tells you this explicitly:
Response for preflight has invalid HTTP status code 401
The browser is then refusing to make the POST request at all.
Consequently the status of the POST request is -1.
You need to respond to the OPTIONS request with a 200 status (and appropriate CORS permissions headers). Then the browser will make a POST request (which you can reject with a 401 if you like).