From f8cf28b0a3bf5cb27d60754f0f1dd79e9cfb038c Mon Sep 17 00:00:00 2001 From: mariomitte Date: Fri, 10 Jul 2026 23:22:53 +0200 Subject: [PATCH] patch astro frontend config file --- frontend/astro.config.mjs | 59 +++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/frontend/astro.config.mjs b/frontend/astro.config.mjs index 3a24e66..316ac7f 100644 --- a/frontend/astro.config.mjs +++ b/frontend/astro.config.mjs @@ -3,20 +3,31 @@ import { defineConfig } from 'astro/config'; import node from '@astrojs/node'; import tailwindcss from '@tailwindcss/vite'; import preact from '@astrojs/preact'; + const isDev = process.env.NODE_ENV === 'development'; -// https://astro.build/config +// CSV iz env-a: "localhost,127.0.0.1,serviseri-004.captain.mitteworkspace.cloud" +const envHosts = (process.env.PUBLIC_ALLOWED_HOSTS || '') + .split(',') + .map((h) => h.trim()) + .filter(Boolean); + +const allowedHosts = Array.from( + new Set(['localhost', '127.0.0.1', ...envHosts]) +); + +const hmrHost = process.env.PUBLIC_HMR_HOST || 'localhost'; +const hmrProtocol = process.env.PUBLIC_HMR_PROTOCOL || 'ws'; +const hmrClientPort = Number(process.env.PUBLIC_HMR_CLIENT_PORT || 4321); + export default defineConfig({ output: 'server', + adapter: node({ mode: 'standalone' }), - adapter: node({ - mode: 'standalone' - }), - - // 🛰️ Postavke razvojnog poslužitelja unutar Docker mreže server: { - host: true, // Sluša na 0.0.0.0 unutar kontejnera - port: 4321, // Unutarnji port kontejnera + host: true, + port: 4321, + allowedHosts, }, vite: { @@ -40,23 +51,23 @@ export default defineConfig({ assetsInlineLimit: 1024, }, plugins: [tailwindcss()], - - // ⚙️ Ugrađene preporuke za Docker File Watching i Tihi Refresh (HMR) - server: isDev ? { - hmr: { - protocol: 'ws', - host: 'localhost', - // Mora odgovarati mapiranom portu u docker-compose (4321:4321) - clientPort: 4321, - }, - watch: { - // Prisiljava Vite na "polling" sustav jer Windows/WSL2 volumeni nekad blokiraju inotify signale - usePolling: true, - interval: 100, - } - } : {}, // U produkciji je ovaj blok potpuno prazan radi maksimalnih performansi + server: isDev + ? { + allowedHosts, + hmr: { + protocol: hmrProtocol, // ws ili wss + host: hmrHost, + clientPort: hmrClientPort, + }, + watch: { + usePolling: true, + interval: 100, + }, + } + : { + allowedHosts, + }, }, - // Redoslijed integracija: Tailwind pa Preact integrations: [preact()], }); \ No newline at end of file