@@ -111,29 +111,23 @@ 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- @@ -271,16 +271,15 @@ export class WebClientServer {
115- return void res.end();
116- }
114+ @@ -285,10 +285,14 @@ export class WebClientServer {
115+ };
117116
118- - const getFirstHeader = (headerName: string) => {
119- - const val = req.headers[headerName];
120- - return Array.isArray(val) ? val[0] : val;
121- - };
122- -
123117 const useTestResolver = (!this._environmentService.isBuilt && this._environmentService.args['use-test-resolver']);
124118+ // For now we are getting the remote authority from the client to avoid
125119+ // needing specific configuration for reverse proxies to work. Set this to
126120+ // something invalid to make sure we catch code that is using this value
127121+ // from the backend when it should not.
128- const remoteAuthority = (
122+ let remoteAuthority = (
129123 useTestResolver
130124 ? 'test+test'
131125- : (getFirstHeader('x-original-host') || getFirstHeader('x-forwarded-host') || req.headers.host)
132126+ : 'remote'
133127 );
134128 if (!remoteAuthority) {
135129 return serveError(req, res, 400, `Bad request.`);
136- @@ -307 ,8 +306 ,12 @@ export class WebClientServer {
130+ @@ -333 ,8 +337 ,12 @@ export class WebClientServer {
137131 scopes: [['user:email'], ['repo']]
138132 } : undefined;
139133
@@ -146,30 +140,30 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
146140 embedderIdentifier: 'server-distro',
147141 extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
148142 ...this._productService.extensionsGallery,
149- @@ -337 ,7 +340 ,7 @@ export class WebClientServer {
143+ @@ -363 ,7 +371 ,7 @@ export class WebClientServer {
150144 folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']),
151145 workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
152146 productConfiguration,
153- - callbackRoute: this._callbackRoute
154- + callbackRoute: vscodeBase + this._callbackRoute
147+ - callbackRoute: callbackRoute
148+ + callbackRoute: vscodeBase + callbackRoute
155149 };
156150
157151 const cookies = cookie.parse(req.headers.cookie || '');
158- @@ -354 ,9 +357 ,11 @@ export class WebClientServer {
152+ @@ -380 ,9 +388 ,11 @@ export class WebClientServer {
159153 const values: { [key: string]: string } = {
160154 WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
161155 WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
162- - WORKBENCH_WEB_BASE_URL: this._staticRoute ,
163- + WORKBENCH_WEB_BASE_URL: vscodeBase + this._staticRoute ,
156+ - WORKBENCH_WEB_BASE_URL: staticRoute ,
157+ + WORKBENCH_WEB_BASE_URL: vscodeBase + staticRoute ,
164158 WORKBENCH_NLS_URL,
165- - WORKBENCH_NLS_FALLBACK_URL: `${this._staticRoute }/out/nls.messages.js`
166- + WORKBENCH_NLS_FALLBACK_URL: `${vscodeBase}${this._staticRoute }/out/nls.messages.js`,
159+ - WORKBENCH_NLS_FALLBACK_URL: `${staticRoute }/out/nls.messages.js`
160+ + WORKBENCH_NLS_FALLBACK_URL: `${vscodeBase}${staticRoute }/out/nls.messages.js`,
167161+ BASE: base,
168162+ VS_BASE: vscodeBase,
169163 };
170164
171165 // DEV ---------------------------------------------------------------------------------------
172- @@ -393 ,7 +398 ,7 @@ export class WebClientServer {
166+ @@ -419 ,7 +429 ,7 @@ export class WebClientServer {
173167 'default-src \'self\';',
174168 'img-src \'self\' https: data: blob:;',
175169 'media-src \'self\';',
@@ -178,7 +172,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
178172 'child-src \'self\';',
179173 `frame-src 'self' https://*.vscode-cdn.net data:;`,
180174 'worker-src \'self\' data: blob:;',
181- @@ -466 ,3 +471 ,70 @@ export class WebClientServer {
175+ @@ -492 ,3 +502 ,70 @@ export class WebClientServer {
182176 return void res.end(data);
183177 }
184178 }
0 commit comments