Skip to content

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

@xelaris

Description

@xelaris

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions