Skip to content

Commit a45ddf5

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

12 files changed

+37
-43
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ 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 {
164+
@@ -327,7 +328,6 @@ export class WebClientServer {
165165

166166
const staticRoute = posix.join(basePath, this._productPath, STATIC_PATH);
167167
const callbackRoute = posix.join(basePath, this._productPath, CALLBACK_PATH);
168168
- const webExtensionRoute = posix.join(basePath, this._productPath, WEB_EXTENSION_PATH);
169169

170170
const resolveWorkspaceURI = (defaultLocation?: string) => defaultLocation && URI.file(path.resolve(defaultLocation)).with({ scheme: Schemas.vscodeRemote, authority: remoteAuthority });
171171

172-
@@ -382,14 +382,22 @@ export class WebClientServer {
172+
@@ -381,14 +381,22 @@ export class WebClientServer {
173173
};
174174

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

patches/external-file-actions.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ 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+
@@ -365,6 +365,8 @@ export class WebClientServer {
116116
serverBasePath: basePath,
117117
webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
118118
userDataPath: this._environmentService.userDataPath,

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+
@@ -369,6 +369,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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ 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+
@@ -360,6 +360,7 @@ export class WebClientServer {
2222
remoteAuthority,
2323
serverBasePath: basePath,
2424
webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',

patches/logout.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ 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+
@@ -343,6 +343,7 @@ export class WebClientServer {
4444
codeServerVersion: this._productService.codeServerVersion,
45-
rootEndpoint: base,
45+
rootEndpoint: rootBase,
4646
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
4747
+ logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
4848
embedderIdentifier: 'server-distro',

patches/marketplace.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ 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+
@@ -343,14 +343,7 @@ export class WebClientServer {
4444
codeServerVersion: this._productService.codeServerVersion,
45-
rootEndpoint: base,
45+
rootEndpoint: rootBase,
4646
embedderIdentifier: 'server-distro',
4747
- extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
4848
- ...this._productService.extensionsGallery,

patches/proxy-uri.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ 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,
74+
@@ -344,6 +344,7 @@ export class WebClientServer {
75+
rootEndpoint: rootBase,
7676
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
7777
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
7878
+ proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}/',

patches/service-worker.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ 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 {
57+
@@ -345,6 +345,10 @@ export class WebClientServer {
5858
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
5959
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
6060
proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}/',

patches/telemetry.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ 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+
@@ -349,6 +349,8 @@ export class WebClientServer {
138138
scope: vscodeBase + '/',
139139
path: base + '/_static/out/browser/serviceWorker.js',
140140
},

patches/update-check.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ 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+
@@ -342,6 +342,7 @@ export class WebClientServer {
109109
const productConfiguration = {
110110
codeServerVersion: this._productService.codeServerVersion,
111-
rootEndpoint: base,
111+
rootEndpoint: rootBase,
112112
+ updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
113113
embedderIdentifier: 'server-distro',
114114
extensionsGallery: this._productService.extensionsGallery,

patches/webview.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ 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+
@@ -356,6 +356,7 @@ export class WebClientServer {
5858
const workbenchWebConfiguration = {
5959
remoteAuthority,
6060
serverBasePath: basePath,

0 commit comments

Comments
 (0)