Rob--W / cors-anywhere

CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxied request.
MIT License
8.57k stars 5.99k forks source link

Status code message not returning when using CORS Anywhere #415

Closed bengrah-miller closed 2 years ago

bengrah-miller commented 2 years ago

Hi there,

We've got an endpoint that if it returns a 500, it will also return an error message:

Status Code: 500 Email address did not match, please get in touch with IT Service Desk for assistance.

I get the above if I make the request directly. If I use CORS Anywhere, the 'Email address did not match...' error doesn't get returned. This is what I get if I use the demo server as an example (e.g. URL is Request URL: https://cors-anywhere.herokuapp.com/https://bengrahURL

Status Code: 500 Internal Server Error

Any ideas why this is?

Thanks, bengrah

hello-smile6 commented 2 years ago

You need a different status code.

hello-smile6 commented 2 years ago

500 is for server-side issues. Consider 401 or 403.

bengrah-miller commented 2 years ago

Hi @hello-smile6 - 403 and 401 don't apply in this instance, as the issue is something not being returned on the server side.

hello-smile6 commented 2 years ago

Hi @hello-smile6 - 403 and 401 don't apply in this instance, as the issue is something not being returned on the server side.

If it's an issue with permissions, send 403.

bengrah-miller commented 2 years ago

It's not an issue with permissions - the endpoint is sent an email address, and if we can't find a match we send back a 500.

Rob--W commented 2 years ago

Without the actual URL it is difficult to tell what's going on. If the API is requested via a website in a browser, the proxy request itself is expected to succeed. Any (erroneous) response is the responsibility of your endpoint.

bengrah-miller commented 2 years ago

Hi @Rob--W

Like I said in my original post, if I make the request directly, I get the response Status Code: 500 Email address did not match, please get in touch with IT Service Desk for assistance. which is what I'd expect.

If I make the request via CORS anywhere, I get Status Code: 500 Internal Server Error - I've already configured the appropriate response via the endpoint, but it appears not to be coming through using CORS anywhere.

Rob--W commented 2 years ago

500 Internal Server Error is not from CORS Anywhere itself either.

Someone recently opened an issue about the same error in #410, where there may be a misconfiguration in nginx.

bengrah-miller commented 2 years ago

Hi @Rob--W - we're not using nginx in our setup. I believe it's just Apache Tomcat - is there any debug or anything like that I can put on to try and highlight the source of this issue?