bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
55 stars 9 forks source link

Break connection instead of returning 504 on network error #163

Closed bjowes closed 3 years ago

bjowes commented 3 years ago

When CORS is in place, Chrome expects all responses from the server to carry the appropriate CORS headers. Otherwise it will reject the response with very limited information for troubleshooting.

This plugin was designed to act as a HTTP/HTTPS proxy, which should return a response with status code 504 when a network error occurs between the proxy and the target server. However, this does not play nicely with Chrome, since the CORS headers will be missing in this case. This leads to investigations of errors in the wrong area (CORS issues instead of connectivity issues).

To mitigate this, the proxy should be updated to act transparently on network errors. It should break the connection to the client if the connection to the target server is lost, and not send any 504 responses. Hopefully this will play nicely with Chrome. There are also certain scenarios where this would be better for Cypress - for instance, by default requests are retried on network errors but not on status code errors.