mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
feat: 支持自托管的 remote-control-server (#214)
* feat: 支持自托管的 remote-control-server (#214) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
@@ -35,12 +35,24 @@ export function isRemoteSessionLocal(
|
||||
|
||||
/**
|
||||
* Get the base URL for Claude AI based on environment.
|
||||
* For localhost, derives the base URL from the ingress URL to preserve the
|
||||
* actual server port instead of using the hardcoded default (4000).
|
||||
*/
|
||||
export function getClaudeAiBaseUrl(
|
||||
sessionId?: string,
|
||||
ingressUrl?: string,
|
||||
): string {
|
||||
if (isRemoteSessionLocal(sessionId, ingressUrl)) {
|
||||
// If an ingress URL is available, extract its origin to keep the correct port.
|
||||
// Self-hosted servers may run on any port (default 3000), not just 4000.
|
||||
if (ingressUrl) {
|
||||
try {
|
||||
const parsed = new URL(ingressUrl)
|
||||
return parsed.origin
|
||||
} catch {
|
||||
// Fall through to default
|
||||
}
|
||||
}
|
||||
return CLAUDE_AI_LOCAL_BASE_URL
|
||||
}
|
||||
if (isRemoteSessionStaging(sessionId, ingressUrl)) {
|
||||
@@ -71,6 +83,12 @@ export function getRemoteSessionUrl(
|
||||
require('../bridge/sessionIdCompat.js') as typeof import('../bridge/sessionIdCompat.js')
|
||||
/* eslint-enable @typescript-eslint/no-require-imports */
|
||||
const compatId = toCompatSessionId(sessionId)
|
||||
// Use CLAUDE_BRIDGE_BASE_URL from env if available, otherwise fall back to default logic
|
||||
const bridgeBaseUrl = process.env.CLAUDE_BRIDGE_BASE_URL
|
||||
if (bridgeBaseUrl) {
|
||||
const base = bridgeBaseUrl.replace(/\/+$/, '')
|
||||
return `${base}/code/${compatId}`
|
||||
}
|
||||
const baseUrl = getClaudeAiBaseUrl(compatId, ingressUrl)
|
||||
return `${baseUrl}/code/${compatId}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user