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

Relative URL for Location response header causes TypeError (e.g. 201 Created) #20

Open
xelaris opened this issue Oct 17, 2023 · 0 comments

Comments

@xelaris
Copy link

xelaris commented Oct 17, 2023

Environment

httpxy 0.1.5
node 20 (but doesn't really matter)

Reproduction

not needed, I think

Describe the bug

If the server responds with a relativ URL in the Location header (e.g. in case of 201 Created), it causes an "Uncaught TypeError: Invalid URL" error, since there is no second parameter to the URL constructor in:

const u = new URL(proxyRes.headers.location);

For example:

HTTP/1.1 201 Created
Location: /api/books/1

Additional context

The Location response header is allowed to contain a relativ URL, according to: https://www.rfc-editor.org/rfc/rfc9110#field.location

The URL constructor needs a base argument in that case: https://nodejs.org/api/url.html#new-urlinput-base

Logs

No response

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

No branches or pull requests

1 participant