Skip to content

Commit 83c9c88

Browse files
committed
Hijack new base path var
1 parent 3c2e337 commit 83c9c88

12 files changed

+58
-64
lines changed

patches/base-path.diff

+21-27
Original file line numberDiff line numberDiff line change
@@ -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
}

patches/display-language.diff

+1-9
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
161161
import { CharCode } from '../../base/common/charCode.js';
162162
import { IExtensionManifest } from '../../platform/extensions/common/extensions.js';
163163
import { ICSSDevelopmentService } from '../../platform/cssDev/node/cssDevService.js';
164-
@@ -325,7 +326,6 @@ export class WebClientServer {
165-
166-
const staticRoute = posix.join(basePath, this._productPath, STATIC_PATH);
167-
const callbackRoute = posix.join(basePath, this._productPath, CALLBACK_PATH);
168-
- const webExtensionRoute = posix.join(basePath, this._productPath, WEB_EXTENSION_PATH);
169-
170-
const resolveWorkspaceURI = (defaultLocation?: string) => defaultLocation && URI.file(path.resolve(defaultLocation)).with({ scheme: Schemas.vscodeRemote, authority: remoteAuthority });
171-
172-
@@ -382,14 +382,22 @@ export class WebClientServer {
164+
@@ -380,14 +381,22 @@ export class WebClientServer {
173165
};
174166

175167
const cookies = cookie.parse(req.headers.cookie || '');

patches/external-file-actions.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
112112
===================================================================
113113
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
114114
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
115-
@@ -366,6 +366,8 @@ export class WebClientServer {
115+
@@ -364,6 +364,8 @@ export class WebClientServer {
116116
serverBasePath: basePath,
117-
webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
117+
webviewEndpoint: staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
118118
userDataPath: this._environmentService.userDataPath,
119119
+ isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
120120
+ isEnabledFileUploads: !this._environmentService.args['disable-file-uploads'],

patches/getting-started.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
201201
===================================================================
202202
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
203203
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
204-
@@ -370,6 +370,7 @@ export class WebClientServer {
204+
@@ -368,6 +368,7 @@ export class WebClientServer {
205205
userDataPath: this._environmentService.userDataPath,
206206
isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
207207
isEnabledFileUploads: !this._environmentService.args['disable-file-uploads'],

patches/local-storage.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
1818
===================================================================
1919
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
2020
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
21-
@@ -361,6 +361,7 @@ export class WebClientServer {
21+
@@ -359,6 +359,7 @@ export class WebClientServer {
2222
remoteAuthority,
2323
serverBasePath: basePath,
24-
webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
24+
webviewEndpoint: staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
2525
+ userDataPath: this._environmentService.userDataPath,
2626
_wrapWebWorkerExtHostInIframe,
2727
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },

patches/logout.diff

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
4040
===================================================================
4141
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
4242
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
43-
@@ -344,6 +344,7 @@ export class WebClientServer {
43+
@@ -342,6 +342,7 @@ export class WebClientServer {
4444
codeServerVersion: this._productService.codeServerVersion,
45-
rootEndpoint: base,
46-
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
47-
+ logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
45+
rootEndpoint: rootBase,
46+
updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
47+
+ logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined,
4848
embedderIdentifier: 'server-distro',
4949
extensionsGallery: this._productService.extensionsGallery,
5050
} satisfies Partial<IProductConfiguration>;

patches/marketplace.diff

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
4040
===================================================================
4141
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
4242
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
43-
@@ -344,14 +344,7 @@ export class WebClientServer {
43+
@@ -327,7 +327,6 @@ export class WebClientServer {
44+
45+
const staticRoute = posix.join(basePath, this._productPath, STATIC_PATH);
46+
const callbackRoute = posix.join(basePath, this._productPath, CALLBACK_PATH);
47+
- const webExtensionRoute = posix.join(basePath, this._productPath, WEB_EXTENSION_PATH);
48+
49+
const resolveWorkspaceURI = (defaultLocation?: string) => defaultLocation && URI.file(path.resolve(defaultLocation)).with({ scheme: Schemas.vscodeRemote, authority: remoteAuthority });
50+
51+
@@ -343,14 +342,7 @@ export class WebClientServer {
4452
codeServerVersion: this._productService.codeServerVersion,
45-
rootEndpoint: base,
53+
rootEndpoint: rootBase,
4654
embedderIdentifier: 'server-distro',
4755
- extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
4856
- ...this._productService.extensionsGallery,

patches/proxy-uri.diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
7171
===================================================================
7272
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
7373
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
74-
@@ -345,6 +345,7 @@ export class WebClientServer {
75-
rootEndpoint: base,
76-
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
77-
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
78-
+ proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}/',
74+
@@ -343,6 +343,7 @@ export class WebClientServer {
75+
rootEndpoint: rootBase,
76+
updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
77+
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined,
78+
+ proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? rootBase + '/proxy/{{port}}/',
7979
embedderIdentifier: 'server-distro',
8080
extensionsGallery: this._productService.extensionsGallery,
8181
} satisfies Partial<IProductConfiguration>;

patches/service-worker.diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
5454
===================================================================
5555
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
5656
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
57-
@@ -346,6 +346,10 @@ export class WebClientServer {
58-
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
59-
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
60-
proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}/',
57+
@@ -344,6 +344,10 @@ export class WebClientServer {
58+
updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
59+
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined,
60+
proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? rootBase + '/proxy/{{port}}/',
6161
+ serviceWorker: {
6262
+ scope: vscodeBase + '/',
63-
+ path: base + '/_static/out/browser/serviceWorker.js',
63+
+ path: rootBase + '/_static/out/browser/serviceWorker.js',
6464
+ },
6565
embedderIdentifier: 'server-distro',
6666
extensionsGallery: this._productService.extensionsGallery,

patches/telemetry.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
134134
===================================================================
135135
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
136136
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
137-
@@ -350,6 +350,8 @@ export class WebClientServer {
137+
@@ -348,6 +348,8 @@ export class WebClientServer {
138138
scope: vscodeBase + '/',
139-
path: base + '/_static/out/browser/serviceWorker.js',
139+
path: rootBase + '/_static/out/browser/serviceWorker.js',
140140
},
141141
+ enableTelemetry: this._productService.enableTelemetry,
142142
+ telemetryEndpoint: this._productService.telemetryEndpoint,

patches/update-check.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
105105
===================================================================
106106
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
107107
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
108-
@@ -343,6 +343,7 @@ export class WebClientServer {
108+
@@ -341,6 +341,7 @@ export class WebClientServer {
109109
const productConfiguration = {
110110
codeServerVersion: this._productService.codeServerVersion,
111-
rootEndpoint: base,
112-
+ updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
111+
rootEndpoint: rootBase,
112+
+ updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
113113
embedderIdentifier: 'server-distro',
114114
extensionsGallery: this._productService.extensionsGallery,
115115
} satisfies Partial<IProductConfiguration>;

patches/webview.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
5454
===================================================================
5555
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
5656
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
57-
@@ -357,6 +357,7 @@ export class WebClientServer {
57+
@@ -355,6 +355,7 @@ export class WebClientServer {
5858
const workbenchWebConfiguration = {
5959
remoteAuthority,
6060
serverBasePath: basePath,
61-
+ webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
61+
+ webviewEndpoint: staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
6262
_wrapWebWorkerExtHostInIframe,
6363
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },
6464
settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined,

0 commit comments

Comments
 (0)