Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow redirects on server responses #82

Merged
merged 1 commit into from Nov 21, 2023

Conversation

MasterOdin
Copy link
Contributor

@MasterOdin MasterOdin commented Nov 21, 2023

Closes #80

PR implements the follow-redirects library into the client, such that if a request to the server returns a 301, it'll be followed, instead of the user getting an execution error:invalid response code (301) error. This is principally to handle the case where a request goes to a HTTP endpoint behind a load balancer, and the load balancer responds with a 301 to upgrade the request to HTTPS.

follow-redirects does offer some options (e.g. whether to follow redirects at all, amount of redirects to follow, etc.), but I don't think it's really meaningful to expose them to end users of the client as I think pretty much all consumers are probably going to be fine with the defaults.

'http:': require('http'),
'https:': require('https'),
'http:': require('follow-redirects/http'),
'https:': require('follow-redirects/https'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it this way is recommended if want to give end-users the ability to fallback to native modules for webpack and friends. See https://www.npmjs.com/package/follow-redirects#browser-usage for more details.

@tagomoris
Copy link
Owner

LGTM.

@tagomoris tagomoris merged commit d475600 into tagomoris:master Nov 21, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nextUri can return 301 redirect due to https/http mismatch
2 participants