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:
parent
9bb819c33e
commit
e8dc48e058
1 changed files with 7 additions and 3 deletions
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in a new issue