Skip to content

Commit

Permalink
Hijack new base path var
Browse files Browse the repository at this point in the history
  • Loading branch information
code-asher committed Feb 12, 2025
1 parent 3c2e337 commit 83c9c88
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 64 deletions.
48 changes: 21 additions & 27 deletions patches/base-path.diff
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,18 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -285,10 +285,14 @@ export class WebClientServer {
@@ -246,7 +246,9 @@ export class WebClientServer {
};

// Prefix routes with basePath for clients
- const basePath = getFirstHeader('x-forwarded-prefix') || this._basePath;
+ const rootBase = relativeRoot(getOriginalUrl(req))
+ const vscodeBase = relativePath(getOriginalUrl(req))
+ const basePath = vscodeBase || getFirstHeader('x-forwarded-prefix') || this._basePath;

const queryConnectionToken = parsedUrl.query[connectionTokenQueryName];
if (typeof queryConnectionToken === 'string') {
@@ -285,10 +287,14 @@ export class WebClientServer {
};

const useTestResolver = (!this._environmentService.isBuilt && this._environmentService.args['use-test-resolver']);
Expand All @@ -127,43 +138,26 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
);
if (!remoteAuthority) {
return serveError(req, res, 400, `Bad request.`);
@@ -333,8 +337,12 @@ export class WebClientServer {
scopes: [['user:email'], ['repo']]
} : undefined;
@@ -335,6 +341,7 @@ export class WebClientServer {

+ const base = relativeRoot(getOriginalUrl(req))
+ const vscodeBase = relativePath(getOriginalUrl(req))
+
const productConfiguration = {
codeServerVersion: this._productService.codeServerVersion,
+ rootEndpoint: base,
+ rootEndpoint: rootBase,
embedderIdentifier: 'server-distro',
extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
...this._productService.extensionsGallery,
@@ -363,7 +371,7 @@ export class WebClientServer {
folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']),
workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
productConfiguration,
- callbackRoute: callbackRoute
+ callbackRoute: vscodeBase + callbackRoute
};

const cookies = cookie.parse(req.headers.cookie || '');
@@ -380,9 +388,11 @@ export class WebClientServer {
const values: { [key: string]: string } = {
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
@@ -382,7 +389,9 @@ export class WebClientServer {
WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
- WORKBENCH_WEB_BASE_URL: staticRoute,
+ WORKBENCH_WEB_BASE_URL: vscodeBase + staticRoute,
WORKBENCH_WEB_BASE_URL: staticRoute,
WORKBENCH_NLS_URL,
- WORKBENCH_NLS_FALLBACK_URL: `${staticRoute}/out/nls.messages.js`
+ WORKBENCH_NLS_FALLBACK_URL: `${vscodeBase}${staticRoute}/out/nls.messages.js`,
+ BASE: base,
+ VS_BASE: vscodeBase,
+ WORKBENCH_NLS_FALLBACK_URL: `${staticRoute}/out/nls.messages.js`,
+ BASE: rootBase,
+ VS_BASE: basePath,
};

// DEV ---------------------------------------------------------------------------------------
@@ -419,7 +429,7 @@ export class WebClientServer {
@@ -419,7 +428,7 @@ export class WebClientServer {
'default-src \'self\';',
'img-src \'self\' https: data: blob:;',
'media-src \'self\';',
Expand All @@ -172,7 +166,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
'child-src \'self\';',
`frame-src 'self' https://*.vscode-cdn.net data:;`,
'worker-src \'self\' data: blob:;',
@@ -492,3 +502,70 @@ export class WebClientServer {
@@ -492,3 +501,70 @@ export class WebClientServer {
return void res.end(data);
}
}
Expand Down
10 changes: 1 addition & 9 deletions patches/display-language.diff
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
import { CharCode } from '../../base/common/charCode.js';
import { IExtensionManifest } from '../../platform/extensions/common/extensions.js';
import { ICSSDevelopmentService } from '../../platform/cssDev/node/cssDevService.js';
@@ -325,7 +326,6 @@ export class WebClientServer {

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

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

@@ -382,14 +382,22 @@ export class WebClientServer {
@@ -380,14 +381,22 @@ export class WebClientServer {
};

const cookies = cookie.parse(req.headers.cookie || '');
Expand Down
4 changes: 2 additions & 2 deletions patches/external-file-actions.diff
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -366,6 +366,8 @@ export class WebClientServer {
@@ -364,6 +364,8 @@ export class WebClientServer {
serverBasePath: basePath,
webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
webviewEndpoint: staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
userDataPath: this._environmentService.userDataPath,
+ isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
+ isEnabledFileUploads: !this._environmentService.args['disable-file-uploads'],
Expand Down
2 changes: 1 addition & 1 deletion patches/getting-started.diff
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -370,6 +370,7 @@ export class WebClientServer {
@@ -368,6 +368,7 @@ export class WebClientServer {
userDataPath: this._environmentService.userDataPath,
isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
isEnabledFileUploads: !this._environmentService.args['disable-file-uploads'],
Expand Down
4 changes: 2 additions & 2 deletions patches/local-storage.diff
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -361,6 +361,7 @@ export class WebClientServer {
@@ -359,6 +359,7 @@ export class WebClientServer {
remoteAuthority,
serverBasePath: basePath,
webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
webviewEndpoint: staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
+ userDataPath: this._environmentService.userDataPath,
_wrapWebWorkerExtHostInIframe,
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },
Expand Down
8 changes: 4 additions & 4 deletions patches/logout.diff
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -344,6 +344,7 @@ export class WebClientServer {
@@ -342,6 +342,7 @@ export class WebClientServer {
codeServerVersion: this._productService.codeServerVersion,
rootEndpoint: base,
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
+ logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
rootEndpoint: rootBase,
updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
+ logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined,
embedderIdentifier: 'server-distro',
extensionsGallery: this._productService.extensionsGallery,
} satisfies Partial<IProductConfiguration>;
Expand Down
12 changes: 10 additions & 2 deletions patches/marketplace.diff
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -344,14 +344,7 @@ export class WebClientServer {
@@ -327,7 +327,6 @@ export class WebClientServer {

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

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

@@ -343,14 +342,7 @@ export class WebClientServer {
codeServerVersion: this._productService.codeServerVersion,
rootEndpoint: base,
rootEndpoint: rootBase,
embedderIdentifier: 'server-distro',
- extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
- ...this._productService.extensionsGallery,
Expand Down
10 changes: 5 additions & 5 deletions patches/proxy-uri.diff
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -345,6 +345,7 @@ export class WebClientServer {
rootEndpoint: base,
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
+ proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}/',
@@ -343,6 +343,7 @@ export class WebClientServer {
rootEndpoint: rootBase,
updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined,
+ proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? rootBase + '/proxy/{{port}}/',
embedderIdentifier: 'server-distro',
extensionsGallery: this._productService.extensionsGallery,
} satisfies Partial<IProductConfiguration>;
Expand Down
10 changes: 5 additions & 5 deletions patches/service-worker.diff
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -346,6 +346,10 @@ export class WebClientServer {
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}/',
@@ -344,6 +344,10 @@ export class WebClientServer {
updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined,
proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? rootBase + '/proxy/{{port}}/',
+ serviceWorker: {
+ scope: vscodeBase + '/',
+ path: base + '/_static/out/browser/serviceWorker.js',
+ path: rootBase + '/_static/out/browser/serviceWorker.js',
+ },
embedderIdentifier: 'server-distro',
extensionsGallery: this._productService.extensionsGallery,
Expand Down
4 changes: 2 additions & 2 deletions patches/telemetry.diff
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -350,6 +350,8 @@ export class WebClientServer {
@@ -348,6 +348,8 @@ export class WebClientServer {
scope: vscodeBase + '/',
path: base + '/_static/out/browser/serviceWorker.js',
path: rootBase + '/_static/out/browser/serviceWorker.js',
},
+ enableTelemetry: this._productService.enableTelemetry,
+ telemetryEndpoint: this._productService.telemetryEndpoint,
Expand Down
6 changes: 3 additions & 3 deletions patches/update-check.diff
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -343,6 +343,7 @@ export class WebClientServer {
@@ -341,6 +341,7 @@ export class WebClientServer {
const productConfiguration = {
codeServerVersion: this._productService.codeServerVersion,
rootEndpoint: base,
+ updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
rootEndpoint: rootBase,
+ updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
embedderIdentifier: 'server-distro',
extensionsGallery: this._productService.extensionsGallery,
} satisfies Partial<IProductConfiguration>;
Expand Down
4 changes: 2 additions & 2 deletions patches/webview.diff
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -357,6 +357,7 @@ export class WebClientServer {
@@ -355,6 +355,7 @@ export class WebClientServer {
const workbenchWebConfiguration = {
remoteAuthority,
serverBasePath: basePath,
+ webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
+ webviewEndpoint: staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
_wrapWebWorkerExtHostInIframe,
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },
settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined,
Expand Down

0 comments on commit 83c9c88

Please sign in to comment.