fix(vite): make dev server host/port configurable via env vars

Replace hardcoded HMR host with VITE_HOST/VITE_PORT env vars.
Set allowedHosts to true and derive origin/HMR config from env,
falling back to defaults when vars are absent.
This commit is contained in:
Andras Bacsai 2026-04-28 22:06:20 +02:00
parent 9bb819c33e
commit e8dc48e058

View file

@ -4,6 +4,8 @@ import vue from "@vitejs/plugin-vue";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const viteHost = env.VITE_HOST || null;
const vitePort = Number(env.VITE_PORT || 5173);
return {
server: {
@ -14,9 +16,11 @@ export default defineConfig(({ mode }) => {
],
},
host: "0.0.0.0",
hmr: {
host: env.VITE_HOST || '0.0.0.0'
},
allowedHosts: true,
origin: viteHost ? `http://${viteHost}:${vitePort}` : undefined,
hmr: viteHost
? { host: viteHost, clientPort: vitePort }
: true,
},
plugins: [
laravel({