To preface this, I am working on a pull request for Syncthing - a continuous file synchronization software. The pull request will allow for an url to be seen for all connected remote machines from the GUI.
The problem I am having is the OPTIONS request is failing to the remote machines. Before the program displays an url to the remote machine, the maintainers have requested that that the GUI verifies the machine will allow the user to visit the remote machine GUI (GET request will fail if the machine has set authentication, so verifying an OPTIONS response is good enough). I can verify the CORS is setup properly. I can even send a curl request and go to the remote machine through the browser, but for whatever reason, the javascript OPTIONS request receives a network error. When I look at the remote machine that will respond to the request, no matter curl, javascript, or browser, it's sends a 201 request back. However, when I look into the chrome network console of the machine sending the request, I see the options request fails, but later on, it seems the request succeeds. My intuition was that the request timeout before the machine sends a valid response and retries. Still, after setting a longer options request header, it does not change result as if the timeout duration is not affecting the error.
This javascript snippet comes from the GUI using angular. It uses angular $http library.
$scope.probeAddress = async function (address, successCallBack) {
try {
var response = await $http({
method: "OPTIONS",
url: address,
timeout: 40000,
});
return response.$$state.status >= 200 && response.$$state.status < 300;
} catch (error) {
console.log(error);
}
}
It responds with a network error, response.$$state = 0.
A picture of the chrome network console. I think it is currently sorted by duration. If sorted in order of received, the red errors would be first. I do not know why the OPTIONS request are retried, but I definitely did not write the code to retry. Both IP Addresses have authentication setup.
A log of one of the machine receiving requests. As you can see, both OPTIONS request receive a 204 response. It says the response was sent in .02ms, while the browser only waits for 112ms