Skip to content

Commit 2b339bc

Browse files
committed
fix(workbench): use window.location without origin
When using `window.location.origin` to create a new URL for loading web packages, it constructs a URL that is not relative, leading to the terminal breaking when code-server is served not via the root (i.e. /ide instead of /).
1 parent 983269f commit 2b339bc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

patches/base-path.diff

+18
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench-dev.html
4949
</head>
5050

5151
<body aria-label="">
52+
@@ -39,7 +39,7 @@
53+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
54+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
55+
<script>
56+
- const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
57+
+ const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location).toString();
58+
Object.keys(self.webPackagePaths).map(function (key, index) {
59+
self.webPackagePaths[key] = `${baseUrl}/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
60+
});
5261
Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
5362
===================================================================
5463
--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.html
@@ -77,6 +86,15 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
7786
<link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.css">
7887

7988
</head>
89+
@@ -38,7 +38,7 @@
90+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
91+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
92+
<script>
93+
- const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
94+
+ const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location).toString();
95+
Object.keys(self.webPackagePaths).map(function (key, index) {
96+
self.webPackagePaths[key] = `${baseUrl}/node_modules/${key}/${self.webPackagePaths[key]}`;
97+
});
8098
Index: code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
8199
===================================================================
82100
--- code-server.orig/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts

0 commit comments

Comments
 (0)