@@ -159,19 +159,26 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
159
159
===================================================================
160
160
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
161
161
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
162
- @@ -253,7 +253 ,10 @@ export class WebClientServer {
162
+ @@ -250,14 +250 ,10 @@ export class WebClientServer {
163
163
return res.end();
164
164
}
165
165
166
- - const remoteAuthority = req.headers.host;
166
+ - let originalHost = req.headers['x-original-host'];
167
+ - if (Array.isArray(originalHost)) {
168
+ - originalHost = originalHost[0];
169
+ - }
170
+ - const remoteAuthority = originalHost || req.headers.host;
171
+ - if (!remoteAuthority) {
172
+ - return serveError(req, res, 400, `Bad request.`);
173
+ - }
167
174
+ // It is not possible to reliably detect the remote authority on the server
168
175
+ // in all cases. Set this to something invalid to make sure we catch code
169
176
+ // that is using this when it should not.
170
177
+ const remoteAuthority = 'remote';
171
178
172
179
function escapeAttribute(value: string): string {
173
180
return value.replace(/"/g, '"');
174
- @@ -275 ,6 +278 ,8 @@ export class WebClientServer {
181
+ @@ -279 ,6 +275 ,8 @@ export class WebClientServer {
175
182
accessToken: this._environmentService.args['github-auth'],
176
183
scopes: [['user:email'], ['repo']]
177
184
} : undefined;
@@ -180,15 +187,15 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
180
187
const data = (await util.promisify(fs.readFile)(filePath)).toString()
181
188
.replace('{{WORKBENCH_WEB_CONFIGURATION}}', escapeAttribute(JSON.stringify({
182
189
remoteAuthority,
183
- @@ -285 ,6 +290 ,7 @@ export class WebClientServer {
190
+ @@ -289 ,6 +287 ,7 @@ export class WebClientServer {
184
191
folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']),
185
192
workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
186
193
productConfiguration: <Partial<IProductConfiguration>>{
187
194
+ rootEndpoint: base,
188
195
codeServerVersion: this._productService.codeServerVersion,
189
196
embedderIdentifier: 'server-distro',
190
197
extensionsGallery: this._webExtensionResourceUrlTemplate ? {
191
- @@ -297 ,7 +303 ,9 @@ export class WebClientServer {
198
+ @@ -301 ,7 +300 ,9 @@ export class WebClientServer {
192
199
} : undefined
193
200
}
194
201
})))
@@ -199,7 +206,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
199
206
200
207
const cspDirectives = [
201
208
'default-src \'self\';',
202
- @@ -376 ,3 +384 ,70 @@ export class WebClientServer {
209
+ @@ -380 ,3 +381 ,70 @@ export class WebClientServer {
203
210
return res.end(data);
204
211
}
205
212
}
@@ -286,15 +293,15 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
286
293
===================================================================
287
294
--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts
288
295
+++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
289
- @@ -482 ,6 +482 ,7 @@ function doCreateUri(path: string, query
296
+ @@ -481 ,6 +481 ,7 @@ function doCreateUri(path: string, query
290
297
});
291
298
}
292
299
293
300
+ path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/")
294
301
return URI.parse(window.location.href).with({ path, query });
295
302
}
296
303
297
- @@ -493 ,7 +494 ,7 @@ function doCreateUri(path: string, query
304
+ @@ -492 ,7 +493 ,7 @@ function doCreateUri(path: string, query
298
305
if (!configElement || !configElementAttribute) {
299
306
throw new Error('Missing web configuration element');
300
307
}
0 commit comments