fix: dev proxy za frontend API pozive
U dev modu frontend sada koristi /api preko Astro/Vite proxy sloja prema backend servisu, umjesto direktnog gađanja localhost:8001 iz browsera.\n\nTime se uklanja ERR_CONNECTION_REFUSED u lokalnom Docker development okruženju.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -34,7 +34,8 @@ services:
|
|||||||
- PUBLIC_HMR_HOST=localhost
|
- PUBLIC_HMR_HOST=localhost
|
||||||
- PUBLIC_HMR_PROTOCOL=ws
|
- PUBLIC_HMR_PROTOCOL=ws
|
||||||
- PUBLIC_HMR_CLIENT_PORT=4321
|
- PUBLIC_HMR_CLIENT_PORT=4321
|
||||||
- PUBLIC_API_URL=http://localhost:8001/api/
|
- PUBLIC_API_URL=http://localhost:4321/api/
|
||||||
|
- PUBLIC_API_PROXY_TARGET=http://backend:8000
|
||||||
|
|
||||||
flower:
|
flower:
|
||||||
container_name: 004erpflower
|
container_name: 004erpflower
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const allowedHosts = Array.from(
|
|||||||
const hmrHost = process.env.PUBLIC_HMR_HOST || 'localhost';
|
const hmrHost = process.env.PUBLIC_HMR_HOST || 'localhost';
|
||||||
const hmrProtocol = process.env.PUBLIC_HMR_PROTOCOL || 'ws';
|
const hmrProtocol = process.env.PUBLIC_HMR_PROTOCOL || 'ws';
|
||||||
const hmrClientPort = Number(process.env.PUBLIC_HMR_CLIENT_PORT || 4321);
|
const hmrClientPort = Number(process.env.PUBLIC_HMR_CLIENT_PORT || 4321);
|
||||||
|
const apiProxyTarget = process.env.PUBLIC_API_PROXY_TARGET || 'http://localhost:8001';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
output: 'server',
|
output: 'server',
|
||||||
@@ -59,6 +60,12 @@ export default defineConfig({
|
|||||||
host: hmrHost,
|
host: hmrHost,
|
||||||
clientPort: hmrClientPort,
|
clientPort: hmrClientPort,
|
||||||
},
|
},
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: apiProxyTarget,
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
usePolling: true,
|
usePolling: true,
|
||||||
interval: 100,
|
interval: 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user