Skip to content

feat: enable forwarded ports using built-in proxy #5673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 24, 2022
Prev Previous commit
Next Next commit
fix: skip uri modification if authority host match
This adds a check in our `resolveExternalUri` patch to skip modifying if
the `authority` and the `location.host` match to prevent
`localhost:<port>/proxy/<port>` from being modified.
  • Loading branch information
jsjoeio committed Oct 20, 2022
commit b98bebb82f39d11cb9afc244dab4c497e67ab85f
4 changes: 2 additions & 2 deletions patches/proxy-uri.diff
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
+ credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider(), // with a remote, we don't use a local credentials provider
+ resolveExternalUri: (uri: URI): Promise<URI> => {
+ let resolvedUri = uri
+ const localhostMatch = extractLocalHostUriMetaDataForPortMapping(uri)
+ const localhostMatch = extractLocalHostUriMetaDataForPortMapping(resolvedUri)
+
+ if (localhostMatch) {
+ if (config.productConfiguration && config.productConfiguration.proxyEndpointTemplate) {
+ if ((resolvedUri.authority !== location.host) && config.productConfiguration && config.productConfiguration.proxyEndpointTemplate) {
+ resolvedUri = URI.parse(new URL(config.productConfiguration.proxyEndpointTemplate.replace('{{port}}', localhostMatch.port.toString()), window.location.href).toString())
+ } else {
+ throw new Error(`Failed to resolve external URI: ${uri.toString()}. Could not determine base url because productConfiguration missing.`)
Expand Down