diff --git a/src/vs/platform/remote/browser/remoteAuthorityResolverService.ts b/src/vs/platform/remote/browser/remoteAuthorityResolverService.ts index a50828715f2e2..07412c7c28062 100644 --- a/src/vs/platform/remote/browser/remoteAuthorityResolverService.ts +++ b/src/vs/platform/remote/browser/remoteAuthorityResolverService.ts @@ -20,7 +20,11 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot private readonly _connectionToken: string | undefined; private readonly _connectionTokens: Map; - constructor(connectionToken: string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined) { + /** + * Add proxy endpoint template. + * @author coder + */ + constructor(connectionToken: string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined, private readonly proxyEndpointUrlTemplate?: string) { super(); this._cache = new Map(); this._connectionToken = connectionToken; @@ -59,12 +63,21 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot private _doResolveAuthority(authority: string): ResolverResult { const connectionToken = this._connectionTokens.get(authority) || this._connectionToken; + /** + * Add VSCODE_PROXY_URI to the environment. + * @author coder + */ + const options = {} + if (this.proxyEndpointUrlTemplate) { + const proxyUrl = new URL(this.proxyEndpointUrlTemplate, window.location.href); + options.extensionHostEnv = { VSCODE_PROXY_URI: decodeURIComponent(proxyUrl.toString()) } + } if (authority.indexOf(':') >= 0) { const pieces = authority.split(':'); - return { authority: { authority, host: pieces[0], port: parseInt(pieces[1], 10), connectionToken } }; + return { authority: { authority, host: pieces[0], port: parseInt(pieces[1], 10), connectionToken }, options }; } const port = (/^https:/.test(window.location.href) ? 443 : 80); - return { authority: { authority, host: authority, port: port, connectionToken } }; + return { authority: { authority, host: authority, port: port, connectionToken }, options }; } _clearResolvedAuthority(authority: string): void { diff --git a/src/vs/server/webClientServer.ts b/src/vs/server/webClientServer.ts index 9978c375f0e16..9c0f0e1cf8f98 100644 --- a/src/vs/server/webClientServer.ts +++ b/src/vs/server/webClientServer.ts @@ -320,10 +320,11 @@ export class WebClientServer { // Endpoints base, logoutEndpointUrl: base + '/logout', + proxyEndpointUrlTemplate: base + '/proxy/{{port}}', webEndpointUrl: vscodeBase + '/static', webEndpointUrlTemplate: vscodeBase + '/static', webviewContentExternalBaseUrlTemplate: vscodeBase + '/webview/{{uuid}}/', - updateUrl: base + '/update/check' + updateUrl: base + '/update/check', }, folderUri: (workspacePath && isFolder) ? transformer.transformOutgoing(URI.file(workspacePath)) : undefined, workspaceUri: (workspacePath && !isFolder) ? transformer.transformOutgoing(URI.file(workspacePath)) : undefined, diff --git a/src/vs/workbench/browser/web.main.ts b/src/vs/workbench/browser/web.main.ts index 14f649b11af0d..0709ce5d408a3 100644 --- a/src/vs/workbench/browser/web.main.ts +++ b/src/vs/workbench/browser/web.main.ts @@ -179,7 +179,11 @@ class BrowserMain extends Disposable { // Remote const connectionToken = environmentService.options.connectionToken || getCookieValue('vscode-tkn'); - const remoteAuthorityResolverService = new RemoteAuthorityResolverService(connectionToken, this.configuration.resourceUriProvider); + /** + * Add proxy URL template to the resolver. + * @author coder + */ + const remoteAuthorityResolverService = new RemoteAuthorityResolverService(connectionToken, this.configuration.resourceUriProvider, this.configuration.productConfiguration?.proxyEndpointUrlTemplate); serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService); // Signing diff --git a/src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts b/src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts index 4fb4083829414..469dd8871ead4 100644 --- a/src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts +++ b/src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts @@ -388,7 +388,11 @@ export function createTerminalEnvironment( // Sanitize the environment, removing any undesirable VS Code and Electron environment // variables - sanitizeProcessEnvironment(env, 'VSCODE_IPC_HOOK_CLI'); + /** + * Do not remove the proxy URI. + * @author coder + */ + sanitizeProcessEnvironment(env, 'VSCODE_IPC_HOOK_CLI', 'VSCODE_PROXY_URI'); // Merge config (settings) and ShellLaunchConfig environments mergeEnvironments(env, allowedEnvFromConfig);