Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/native/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub async fn install_domain_filter_script(
const OrigWS = window.WebSocket;
window.WebSocket = function(url, protocols) {{
try {{
const u = new URL(url);
const u = new URL(url, location.href);
if (!_isDomainAllowed(u.hostname)) throw new DOMException('WebSocket blocked: ' + u.hostname, 'SecurityError');
}} catch(e) {{ if (e instanceof DOMException) throw e; }}
return new OrigWS(url, protocols);
Expand Down
3 changes: 2 additions & 1 deletion src/domain-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export function buildWebSocketFilterScript(allowedDomains: string[]): string {
}
function _checkUrl(url) {
try {
var parsed = new URL(url);
// Resolve relative URLs against current page origin (e.g., /__webpack_hmr)
var parsed = new URL(url, location.href);
return _isDomainAllowed(parsed.hostname);
} catch(e) {
return false;
Expand Down