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 a45ddf5
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 43 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
4 changes: 2 additions & 2 deletions patches/display-language.diff
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ 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 {
@@ -327,7 +328,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 {
@@ -381,14 +381,22 @@ export class WebClientServer {
};

const cookies = cookie.parse(req.headers.cookie || '');
Expand Down
2 changes: 1 addition & 1 deletion patches/external-file-actions.diff
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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
@@ -366,6 +366,8 @@ export class WebClientServer {
@@ -365,6 +365,8 @@ export class WebClientServer {
serverBasePath: basePath,
webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
userDataPath: this._environmentService.userDataPath,
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 {
@@ -369,6 +369,7 @@ export class WebClientServer {
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/local-storage.diff
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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
@@ -361,6 +361,7 @@ export class WebClientServer {
@@ -360,6 +360,7 @@ export class WebClientServer {
remoteAuthority,
serverBasePath: basePath,
webviewEndpoint: vscodeBase + staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
Expand Down
4 changes: 2 additions & 2 deletions patches/logout.diff
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,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
@@ -344,6 +344,7 @@ export class WebClientServer {
@@ -343,6 +343,7 @@ export class WebClientServer {
codeServerVersion: this._productService.codeServerVersion,
rootEndpoint: base,
rootEndpoint: rootBase,
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
+ logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
embedderIdentifier: 'server-distro',
Expand Down
4 changes: 2 additions & 2 deletions patches/marketplace.diff
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,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
@@ -344,14 +344,7 @@ export class WebClientServer {
@@ -343,14 +343,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
4 changes: 2 additions & 2 deletions patches/proxy-uri.diff
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ 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,
@@ -344,6 +344,7 @@ export class WebClientServer {
rootEndpoint: rootBase,
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}}/',
Expand Down
2 changes: 1 addition & 1 deletion patches/service-worker.diff
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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
@@ -346,6 +346,10 @@ export class WebClientServer {
@@ -345,6 +345,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}}/',
Expand Down
2 changes: 1 addition & 1 deletion patches/telemetry.diff
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,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
@@ -350,6 +350,8 @@ export class WebClientServer {
@@ -349,6 +349,8 @@ export class WebClientServer {
scope: vscodeBase + '/',
path: base + '/_static/out/browser/serviceWorker.js',
},
Expand Down
4 changes: 2 additions & 2 deletions patches/update-check.diff
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,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
@@ -343,6 +343,7 @@ export class WebClientServer {
@@ -342,6 +342,7 @@ export class WebClientServer {
const productConfiguration = {
codeServerVersion: this._productService.codeServerVersion,
rootEndpoint: base,
rootEndpoint: rootBase,
+ updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
embedderIdentifier: 'server-distro',
extensionsGallery: this._productService.extensionsGallery,
Expand Down
2 changes: 1 addition & 1 deletion patches/webview.diff
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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
@@ -357,6 +357,7 @@ export class WebClientServer {
@@ -356,6 +356,7 @@ export class WebClientServer {
const workbenchWebConfiguration = {
remoteAuthority,
serverBasePath: basePath,
Expand Down

0 comments on commit a45ddf5

Please sign in to comment.