Skip to content

fix: handle relative URLs in WebSocket domain filter#767

Open
Jah-yee wants to merge 1 commit intovercel-labs:mainfrom
Jah-yee:main
Open

fix: handle relative URLs in WebSocket domain filter#767
Jah-yee wants to merge 1 commit intovercel-labs:mainfrom
Jah-yee:main

Conversation

@Jah-yee
Copy link

@Jah-yee Jah-yee commented Mar 13, 2026

Resolves TypeError when WebSocket connections use relative URLs like /__webpack_hmr (webpack HMR endpoints).

Problem

In src/domain-filter.ts and cli/src/native/network.rs, the WebSocket URL was parsed with:

var parsed = new URL(url);

new URL(url) requires an absolute URL. Relative paths (e.g. /__webpack_hmr) need a base URL to resolve against, otherwise the constructor throws a TypeError.

Solution

Use location.href as the base URL when parsing:

var parsed = new URL(url, location.href);

This allows relative WebSocket URLs (like webpack HMR endpoints) to be properly resolved against the current page origin without throwing an error.

Files Changed

  • src/domain-filter.ts_checkUrl() function
  • cli/src/native/network.rs — inline WebSocket filter script

Resolves TypeError when WebSocket connections use relative URLs
like /__webpack_hmr (webpack HMR endpoints).

- domain-filter.ts: Use location.href as base URL for new URL()
- network.rs: Same fix for inline WebSocket filter script

Previously, new URL(url) threw TypeError on relative URLs because
it requires an absolute URL. Now we resolve against location.href
to properly handle relative paths.
@vercel
Copy link
Contributor

vercel bot commented Mar 13, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant