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

Support path-only WebSocket URLs in hosted mode #4

Merged
merged 1 commit into from
Feb 23, 2024
Merged
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
10 changes: 9 additions & 1 deletion front_end/core/sdk/Connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,15 @@ function createMainConnection(websocketConnectionLost: () => void): ProtocolClie
const wsParam = Root.Runtime.Runtime.queryParam('ws');
const wssParam = Root.Runtime.Runtime.queryParam('wss');
if (wsParam || wssParam) {
const ws = (wsParam ? `ws://${wsParam}` : `wss://${wssParam}`) as Platform.DevToolsPath.UrlString;
const scheme = wsParam ? 'ws' : 'wss';
// ws[s]Param is either:
// 1. The hierarchical part of a URL (with the scheme and :// removed).
// 2. A path-absolute URL (beginning with `/`) relative to the current host. This is only meaningful in hosted mode.
let schemelessUrl = (wsParam ? wsParam : wssParam) as string;
if (Host.InspectorFrontendHost.InspectorFrontendHostInstance.isHostedMode() && schemelessUrl.startsWith('/')) {
schemelessUrl = `${window.location.host}${schemelessUrl}`;
}
const ws = `${scheme}://${schemelessUrl}` as Platform.DevToolsPath.UrlString;
return new WebSocketConnection(ws, websocketConnectionLost);
}
if (Host.InspectorFrontendHost.InspectorFrontendHostInstance.isHostedMode()) {
Expand Down
Loading