@@ -111,7 +111,18 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
111111===================================================================
112112--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
113113+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
114- @@ -285,10 +285,14 @@ export class WebClientServer {
114+ @@ -246,7 +246,9 @@ export class WebClientServer {
115+ };
116+
117+ // Prefix routes with basePath for clients
118+ - const basePath = getFirstHeader('x-forwarded-prefix') || this._basePath;
119+ + const rootBase = relativeRoot(getOriginalUrl(req))
120+ + const vscodeBase = relativePath(getOriginalUrl(req))
121+ + const basePath = vscodeBase || getFirstHeader('x-forwarded-prefix') || this._basePath;
122+
123+ const queryConnectionToken = parsedUrl.query[connectionTokenQueryName];
124+ if (typeof queryConnectionToken === 'string') {
125+ @@ -285,10 +287,14 @@ export class WebClientServer {
115126 };
116127
117128 const useTestResolver = (!this._environmentService.isBuilt && this._environmentService.args['use-test-resolver']);
@@ -127,43 +138,26 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
127138 );
128139 if (!remoteAuthority) {
129140 return serveError(req, res, 400, `Bad request.`);
130- @@ -333,8 +337,12 @@ export class WebClientServer {
131- scopes: [['user:email'], ['repo']]
132- } : undefined;
141+ @@ -335,6 +341,7 @@ export class WebClientServer {
133142
134- + const base = relativeRoot(getOriginalUrl(req))
135- + const vscodeBase = relativePath(getOriginalUrl(req))
136- +
137143 const productConfiguration = {
138144 codeServerVersion: this._productService.codeServerVersion,
139- + rootEndpoint: base ,
145+ + rootEndpoint: rootBase ,
140146 embedderIdentifier: 'server-distro',
141147 extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
142148 ...this._productService.extensionsGallery,
143- @@ -363,7 +371,7 @@ export class WebClientServer {
144- folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']),
145- workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
146- productConfiguration,
147- - callbackRoute: callbackRoute
148- + callbackRoute: vscodeBase + callbackRoute
149- };
150-
151- const cookies = cookie.parse(req.headers.cookie || '');
152- @@ -380,9 +388,11 @@ export class WebClientServer {
153- const values: { [key: string]: string } = {
154- WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
149+ @@ -382,7 +389,9 @@ export class WebClientServer {
155150 WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
156- - WORKBENCH_WEB_BASE_URL: staticRoute,
157- + WORKBENCH_WEB_BASE_URL: vscodeBase + staticRoute,
151+ WORKBENCH_WEB_BASE_URL: staticRoute,
158152 WORKBENCH_NLS_URL,
159153- WORKBENCH_NLS_FALLBACK_URL: `${staticRoute}/out/nls.messages.js`
160- + WORKBENCH_NLS_FALLBACK_URL: `${vscodeBase}${ staticRoute}/out/nls.messages.js`,
161- + BASE: base ,
162- + VS_BASE: vscodeBase ,
154+ + WORKBENCH_NLS_FALLBACK_URL: `${staticRoute}/out/nls.messages.js`,
155+ + BASE: rootBase ,
156+ + VS_BASE: basePath ,
163157 };
164158
165159 // DEV ---------------------------------------------------------------------------------------
166- @@ -419,7 +429 ,7 @@ export class WebClientServer {
160+ @@ -419,7 +428 ,7 @@ export class WebClientServer {
167161 'default-src \'self\';',
168162 'img-src \'self\' https: data: blob:;',
169163 'media-src \'self\';',
@@ -172,7 +166,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
172166 'child-src \'self\';',
173167 `frame-src 'self' https://*.vscode-cdn.net data:;`,
174168 'worker-src \'self\' data: blob:;',
175- @@ -492,3 +502 ,70 @@ export class WebClientServer {
169+ @@ -492,3 +501 ,70 @@ export class WebClientServer {
176170 return void res.end(data);
177171 }
178172 }
0 commit comments