Skip to content

crash when 'options.target' is an object instead a string#1600

Open
vilherda wants to merge 1 commit intohttp-party:masterfrom
vilherda:patch-1
Open

crash when 'options.target' is an object instead a string#1600
vilherda wants to merge 1 commit intohttp-party:masterfrom
vilherda:patch-1

Conversation

@vilherda
Copy link
Copy Markdown

Sometimes the attribute 'options.target' is not a string and is an object like:

{
    "protocol": "http:",
    "slashes": true,
    "auth": null,
    "host": "some.hostname.fake",
    "port": null,
    "hostname": "some.hostname.fake",
    "hash": null,
    "search": null,
    "query": null,
    "pathname": "/",
    "path": "/",
    "href": "http://some.hostname.fake"
}

In this case is necessary to access to the attribute 'options.target.href'.

Sometimes the attribute 'options.target' is not a string and is an object like:
```json
{
    "protocol": "http:",
    "slashes": true,
    "auth": null,
    "host": "some.hostname.fake",
    "port": null,
    "hostname": "some.hostname.fake",
    "hash": null,
    "search": null,
    "query": null,
    "pathname": "/",
    "path": "/",
    "href": "http://some.hostname.fake"
}
```
In this case is necessary to access to the attribute 'options.target.href'.
pi0 added a commit to unjs/httpxy that referenced this pull request Mar 25, 2026
When `options.target` is a `ProxyTargetDetailed` object (not a string
or URL), `setRedirectHostRewrite` crashed with `Invalid URL` because
`new URL()` cannot parse a plain object. Construct the URL from the
object's `protocol`, `host`/`hostname`, and `port` properties instead.

Upstream: http-party/node-http-proxy#1600
pi0 added a commit to unjs/httpxy that referenced this pull request Mar 25, 2026
When `options.target` is a `ProxyTargetDetailed` object (not a string
or URL), `setRedirectHostRewrite` crashed with `Invalid URL` because
`new URL()` cannot parse a plain object. Construct the URL from the
object's `protocol`, `host`/`hostname`, and `port` properties instead.

Upstream: http-party/node-http-proxy#1600
@pi0
Copy link
Copy Markdown

pi0 commented Mar 25, 2026

This issue has been fixed in unjs/httpxy#108.

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.

3 participants