mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-17 11:57:23 +00:00
* fix: remove --host from npm run server command Running `vite --host` exposes the dev server on all interfaces. However, we should expose it on all interfaces only when `HOST` is set to `0.0.0.0`. Otherwise, we should assume the user wants to bind to a host of their choice and not expose the server on the network. * fix: use src hostname for redirecting to Vite in development Previously, the server redirected to Vite using `localhost` as the hostname. Even if the user was using HOST="0.0.0.0", if they connected to server from another device on the same network using `http://<host_ip>:3001`, the server would redirect them to `http://localhost:5173`, which would not work since `localhost` would resolve to the client's machine instead of the server. * fix: use shared network hosts configuration for better proxy setup - Normalize all localhost variants to 'localhost' for consistent proxy configuration in Vite and server setup. - use one source of truth for network hosts functions by moving them to a shared - log production and development urls * refactor: rename PORT to SERVER_PORT for clarity * chore: add comments explaining host normalization * fix: add legacy PORT env fallback for server port configuration * fix: add fallback for SERVER_PORT using PORT environment variable --------- Co-authored-by: Haileyesus <something@gmail.com> Co-authored-by: Simos Mikelatos <simosmik@gmail.com>
23 lines
613 B
JavaScript
23 lines
613 B
JavaScript
export function isWildcardHost(host) {
|
|
return host === '0.0.0.0' || host === '::';
|
|
}
|
|
|
|
export function isLoopbackHost(host) {
|
|
return host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '[::1]';
|
|
}
|
|
|
|
export function normalizeLoopbackHost(host) {
|
|
if (!host) {
|
|
return host;
|
|
}
|
|
return isLoopbackHost(host) ? 'localhost' : host;
|
|
}
|
|
|
|
// Use localhost for connectable loopback and wildcard addresses in browser-facing URLs.
|
|
export function getConnectableHost(host) {
|
|
if (!host) {
|
|
return 'localhost';
|
|
}
|
|
return isWildcardHost(host) || isLoopbackHost(host) ? 'localhost' : host;
|
|
}
|