Skip to content

Commit 768b0c8

Browse files
committed
fixup!: update patch
1 parent 093ebf8 commit 768b0c8

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

patches/proxy-uri.diff

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
106106
import { create, ICredentialsProvider, IURLCallbackProvider, IWorkbenchConstructionOptions, IWorkspace, IWorkspaceProvider } from 'vs/workbench/workbench.web.main';
107107
import { posix } from 'vs/base/common/path';
108108
import { ltrim } from 'vs/base/common/strings';
109-
+import { relativeRoot } from 'vs/server/node/webClientServer';
109+
+import { extractLocalHostUriMetaDataForPortMapping } from 'vs/platform/tunnel/common/tunnel';
110110

111111
interface ICredential {
112112
service: string;
@@ -127,33 +127,23 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
127127

128128
// Create workbench
129129
create(document.body, {
130-
@@ -506,6 +508,32 @@ function doCreateUri(path: string, query
130+
@@ -506,6 +508,22 @@ function doCreateUri(path: string, query
131131
} : undefined,
132132
workspaceProvider: WorkspaceProvider.create(config),
133133
urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute),
134134
- credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider() // with a remote, we don't use a local credentials provider
135135
+ credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider(), // with a remote, we don't use a local credentials provider
136136
+ resolveExternalUri: (uri: URI): Promise<URI> => {
137-
+ // TODO@jsjoeio - how do we make it relative to work when hosted on subpath?
138-
+ const baseUrl = `${window.location.protocol}//${window.location.host}`
139137
+ let resolvedUri = uri
138+
+ const localhostMatch = extractLocalHostUriMetaDataForPortMapping(uri)
140139
+
141-
+ // NOTE@jsjoeio - this isn't exhaustive
142-
+ // also doesn't handle if not http or https i.e. ws
143-
+ const localhostMatch = uri.toString().includes("localhost")
144140
+ if (localhostMatch) {
145-
+ // Source: extractLocalHostUriMetaDataForPortMapping
146-
+ const matches = /^(localhost|127\.0\.0\.1|0\.0\.0\.0):(\d+)$/.exec(uri.authority)
147-
+ const port = matches && +matches[2]
148-
+ if (port) {
149-
+ // Use code-server's built in /proxy/<port>
150-
+ resolvedUri = URI.parse(`${baseUrl}/proxy/${port}`)
151-
+ } else {
152-
+ // If here probably means no port found
153-
+ // Assume 80 for HTTP and 443 for HTTPS
154-
+ const isHttps = uri.scheme === "https"
155-
+ resolvedUri = URI.parse(`${baseUrl}/proxy/${isHttps ? "443" : "80"}`)
141+
+ let baseUrl = `${window.location.protocol}//${window.location.host}`
142+
+ if (config.productConfiguration && config.productConfiguration.proxyEndpointTemplate) {
143+
+ baseUrl = new URL(config.productConfiguration.proxyEndpointTemplate.replace('{{port}}', localhostMatch.port.toString()), window.location.href).toString()
156144
+ }
145+
+ // Use code-server's built in /proxy/<port>
146+
+ resolvedUri = URI.parse(`${baseUrl}/proxy/${localhostMatch.port}`)
157147
+ }
158148
+
159149
+ // If not localhost, return unmodified

0 commit comments

Comments
 (0)