From bd31ffbff43b252cfee453a0fa6f079b76e37f80 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Fri, 5 Dec 2025 16:37:38 +0200 Subject: [PATCH] fix front conn --- frontend/10-generate-env.sh | 23 +++++++++++++++++++++ frontend/nginx.conf | 41 +++++++++++++++++++++++++++++++++++++ frontend/src/api.js | 11 +++++++++- 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 frontend/10-generate-env.sh create mode 100644 frontend/nginx.conf diff --git a/frontend/10-generate-env.sh b/frontend/10-generate-env.sh new file mode 100644 index 0000000..0fbacc6 --- /dev/null +++ b/frontend/10-generate-env.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +TEMPLATE="/etc/env/env.js.template" +TARGET="/usr/share/nginx/html/env.js" + +if [ -f "$TEMPLATE" ]; then + echo "Generating env.js from template with API_BASE=${API_BASE:-/api}" + # Default API_BASE to /api if not provided + : ${API_BASE:=/api} + + cat > "$TARGET" < { + if (typeof window !== "undefined" && window.__ENV__ && window.__ENV__.API_BASE) { + return window.__ENV__.API_BASE; + } + // Default to relative /api path for local/containerized deployments + return "/api"; +}; + +const API_BASE = getApiBase(); export async function getRecipes() { const res = await fetch(`${API_BASE}/recipes`);