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
This commit is contained in:
Haileyesus
2026-03-11 15:44:01 +03:00
parent 0049ff51ee
commit f3b25bbbab
3 changed files with 35 additions and 10 deletions

22
shared/networkHosts.js Normal file
View File

@@ -0,0 +1,22 @@
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;
}