feat: enhance local provider URL validation to include private IPv4 and IPv6 addresses

This commit is contained in:
James Shawn Carnley
2026-04-02 12:26:23 -04:00
parent 73db9b5fd3
commit 4a4394bb65
4 changed files with 67 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
import { feature } from 'bun:bundle';
import {
isLocalProviderUrl,
resolveCodexApiCredentials,
resolveProviderRequest,
} from '../services/api/providerConfig.js'
@@ -40,16 +41,6 @@ function isEnvTruthy(value: string | undefined): boolean {
return normalized !== '' && normalized !== '0' && normalized !== 'false' && normalized !== 'no'
}
function isLocalProviderUrl(baseUrl: string | undefined): boolean {
if (!baseUrl) return false
try {
const parsed = new URL(baseUrl)
return parsed.hostname === 'localhost' || parsed.hostname === '127.0.0.1' || parsed.hostname === '::1'
} catch {
return false
}
}
function getProviderValidationError(
env: NodeJS.ProcessEnv = process.env,
): string | null {