Add configurable service proxy (#1280)
* Add configurable service proxy * Fix service proxy URL used when opening scripts with a public base URL When a public proxy URL was configured, the View link was falling through to direct connection logic and opening the wrong URL. Move the public URL early-return before connection-type checks, and remove the now-dead duplicate check further down. * Add service proxy documentation Covers config options, URL generation format, wildcard DNS setup, and reverse proxy Host header requirements. * Cap combined public service label and document hostname format * Address service proxy review feedback
This commit is contained in:
@@ -14,6 +14,19 @@ function isLoopbackHost(host: string): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function isLocalOnlyUrl(url: string | null | undefined): boolean {
|
||||
if (!url) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
const hostname = parsed.hostname.toLowerCase();
|
||||
return isLoopbackHost(hostname) || hostname.endsWith(".localhost");
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function buildDirectServiceUrl(endpoint: string, port: number): string | null {
|
||||
try {
|
||||
const { host, isIpv6 } = parseHostPort(endpoint);
|
||||
@@ -37,6 +50,12 @@ export function resolveWorkspaceScriptLink(input: {
|
||||
return { openUrl: null, labelUrl: script.proxyUrl };
|
||||
}
|
||||
|
||||
const proxyUrlIsLocalOnly = isLocalOnlyUrl(script.proxyUrl);
|
||||
|
||||
if (!proxyUrlIsLocalOnly) {
|
||||
return { openUrl: script.proxyUrl, labelUrl: script.proxyUrl };
|
||||
}
|
||||
|
||||
if (activeConnection.type === "relay") {
|
||||
return { openUrl: null, labelUrl: script.proxyUrl };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user