@@ -14,11 +14,12 @@ Index: code-server/lib/vscode/src/vs/base/common/product.ts
1414===================================================================
1515--- code-server.orig/lib/vscode/src/vs/base/common/product.ts
1616+++ code-server/lib/vscode/src/vs/base/common/product.ts
17- @@ -35,6 +35,7 @@ export interface IProductConfiguration {
17+ @@ -35,6 +35,8 @@ export interface IProductConfiguration {
1818 readonly rootEndpoint?: string
1919 readonly updateEndpoint?: string
2020 readonly logoutEndpoint?: string
2121+ readonly proxyEndpointTemplate?: string
22+ + readonly proxyDomain?: string
2223
2324 readonly version: string;
2425 readonly date?: string;
@@ -40,17 +41,26 @@ Index: code-server/lib/vscode/src/vs/platform/remote/browser/remoteAuthorityReso
4041 private readonly _connectionTokens: Map<string, string>;
4142
4243- constructor(@IProductService productService: IProductService, connectionToken: Promise<string> | string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined) {
43- + constructor(@IProductService productService: IProductService, connectionToken: Promise<string> | string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined, private readonly proxyEndpointTemplate?: string) {
44+ + constructor(@IProductService productService: IProductService, connectionToken: Promise<string> | string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined, private readonly proxyEndpointTemplate?: string, private readonly proxyDomain?: string ) {
4445 super();
4546 this._connectionToken = connectionToken;
4647 this._connectionTokens = new Map<string, string>();
47- @@ -61,9 +61,14 @@ export class RemoteAuthorityResolverServ
48+ @@ -61,9 +61,23 @@ export class RemoteAuthorityResolverServ
4849
4950 private async _doResolveAuthority(authority: string): Promise<ResolverResult> {
5051 const connectionToken = await Promise.resolve(this._connectionTokens.get(authority) || this._connectionToken);
5152+ let options: ResolvedOptions | undefined;
5253+ if (this.proxyEndpointTemplate) {
53- + const proxyUrl = new URL(this.proxyEndpointTemplate, window.location.href);
54+ + let proxyUrl = new URL(this.proxyEndpointTemplate, window.location.href);
55+ + // TODO@jsjoeio - check for host match
56+ + if (this.proxyDomain) {
57+ + const host = window.location.host
58+ + const hostAndProxyDomainMatch = host === this.proxyDomain
59+ +
60+ + if(hostAndProxyDomainMatch) {
61+ + proxyUrl = new URL(this.proxyDomain, window.location.href);
62+ + }
63+ + }
5464+ options = { extensionHostEnv: { VSCODE_PROXY_URI: decodeURIComponent(proxyUrl.toString()) }}
5565+ }
5666 const defaultPort = (/^https:/.test(window.location.href) ? 443 : 80);
@@ -64,14 +74,20 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
6474===================================================================
6575--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
6676+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
67- @@ -314,6 +314,7 @@ export class WebClientServer {
77+ @@ -314,10 +314,12 @@ export class WebClientServer {
6878 rootEndpoint: base,
6979 updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
7080 logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
7181+ proxyEndpointTemplate: base + '/proxy/{{port}}',
7282 embedderIdentifier: 'server-distro',
7383 extensionsGallery: this._productService.extensionsGallery,
7484 },
85+ - callbackRoute: this._callbackRoute
86+ + callbackRoute: this._callbackRoute,
87+ + proxyDomain: this._environmentService.args['proxyDomain'] ? `{{port}}.${this._environmentService.args['proxyDomain']}` : undefined
88+ };
89+
90+ const nlsBaseUrl = this._productService.extensionsGallery?.nlsBaseUrl;
7591Index: code-server/lib/vscode/src/vs/workbench/browser/web.main.ts
7692===================================================================
7793--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.main.ts
@@ -81,7 +97,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/web.main.ts
8197 // Remote
8298 const connectionToken = environmentService.options.connectionToken || getCookieValue(connectionTokenCookieName);
8399- const remoteAuthorityResolverService = new RemoteAuthorityResolverService(productService, connectionToken, this.configuration.resourceUriProvider);
84- + const remoteAuthorityResolverService = new RemoteAuthorityResolverService(productService, connectionToken, this.configuration.resourceUriProvider, this.configuration.productConfiguration?.proxyEndpointTemplate);
100+ + const remoteAuthorityResolverService = new RemoteAuthorityResolverService(productService, connectionToken, this.configuration.resourceUriProvider, this.configuration.productConfiguration?.proxyEndpointTemplate, this.configuration.productConfiguration?.proxyDomain );
85101 serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
86102
87103 // Signing
@@ -133,3 +149,38 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
133149+ }
134150 });
135151 })();
152+ Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
153+ ===================================================================
154+ --- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts
155+ +++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
156+ @@ -328,6 +328,8 @@ export interface IWorkbenchConstructionO
157+
158+ //#endregion
159+
160+ + readonly proxyDomain?: string;
161+ +
162+ }
163+
164+ export interface IResourceUriProvider {
165+ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
166+ ===================================================================
167+ --- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
168+ +++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
169+ @@ -14,6 +14,7 @@ export const serverOptions: OptionDescri
170+ /* ----- code-server ----- */
171+ 'disable-update-check': { type: 'boolean' },
172+ 'auth': { type: 'string' },
173+ + 'proxyDomain': { type: 'string' },
174+
175+ /* ----- server setup ----- */
176+
177+ @@ -94,7 +95,8 @@ export const serverOptions: OptionDescri
178+ export interface ServerParsedArgs {
179+ /* ----- code-server ----- */
180+ 'disable-update-check'?: boolean;
181+ - 'auth'?: string
182+ + 'auth'?: string;
183+ + 'proxyDomain'?: string;
184+
185+ /* ----- server setup ----- */
186+
0 commit comments