chore: add comments explaining host normalization

This commit is contained in:
Haileyesus
2026-03-11 16:05:26 +03:00
parent 468ab599be
commit 1995a411d2

View File

@@ -2,12 +2,17 @@ import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { getConnectableHost, normalizeLoopbackHost } from './shared/networkHosts.js'
export default defineConfig(({ command, mode }) => {
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
const env = loadEnv(mode, process.cwd(), '')
const configuredHost = env.HOST || '0.0.0.0'
// if the host is not a loopback address, it should be used directly.
// This allows the vite server to EXPOSE all interfaces when the host
// is set to '0.0.0.0' or '::', while still using 'localhost' for browser
// URLs and proxy targets.
const host = normalizeLoopbackHost(configuredHost)
const proxyHost = getConnectableHost(configuredHost)
const serverPort = env.SERVER_PORT || 3001