The HEALTHCHECK added an hour ago recreated the exact symptom. Dokploy runs applications as Docker Swarm services, and Swarm does not merely report an unhealthy task — it removes it from the service load balancer and reschedules it. /api/health answers 503 while a required variable is missing, so: AUTH_SECRET unset -> /api/health 503 -> task unhealthy -> pulled out of the load balancer -> Traefik has no backend -> 502 Bad Gateway on every url. The container was up and serving a 503 that names the fault, and nothing could reach it to read that 503. "A broken deploy must not look healthy" is a real concern, but enforcing it in the orchestrator destroys the diagnostics, and an outage whose reason cannot be seen is the more expensive failure. The container now stays in rotation whenever it can serve HTTP at all. Also, two things that make a secret that was SET look like one that was not: - Recommend `openssl rand -hex 32` everywhere instead of `openssl rand -base64 48`. A base64 value ends in '=' and may contain '+' and '/'; pasted into a dashboard field or a KEY=VALUE editor that splits on the first '=', it can be stored truncated or empty, which is indistinguishable from never setting it. Hex is [0-9a-f] only, so there is nothing for a parser to mangle. - Treat a whitespace-only AUTH_SECRET as missing, and print the secret's LENGTH (never its value) in the boot log. `openssl rand -hex 32` is 64 characters, so a much shorter number there is a value that arrived truncated — which otherwise presents as sessions that do not verify, with nothing to explain it. Verified on the rebuilt standalone payload: absent -> container alive, 503 `x-loyaly-config: misconfigured` on /, /login and /api/sites; whitespace -> the same; a real hex secret -> / 307, /login 200, /favicon.ico 200, /api/health 200 and `auth secret set (64 chars)` in the log. tsc --noEmit and eslint clean, production build exits 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
39 lines
1.8 KiB
Plaintext
39 lines
1.8 KiB
Plaintext
# ---------------------------------------------------------------------------
|
|
# Template for `.env.local` — your LOCAL overrides. Copy it:
|
|
#
|
|
# cp .env.example .env.local
|
|
#
|
|
# Do not copy it to `.env`. `.env` is committed and already holds the
|
|
# production values; `.env.local` is loaded ahead of it and is gitignored.
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# The one shared Loyaly platform API (Behavision). Server-side only and
|
|
# deliberately NOT NEXT_PUBLIC: publishing the host would let a browser bypass
|
|
# the BFF, which is what keeps the access token out of JavaScript.
|
|
#
|
|
# local dev http://127.0.0.1:8088 ← what belongs in .env.local
|
|
# production https://mcp.loyaly.ai ← already set in the committed .env
|
|
#
|
|
# NOT platform.loyaly.ai — that host serves THIS console, not the API. Pointing
|
|
# the variable there makes the BFF call its own origin, which fails in a way
|
|
# that looks like a broken login form rather than a misconfiguration.
|
|
#
|
|
# There is no remote fallback: production refuses to serve without this set.
|
|
# That is why it is committed in `.env` rather than left to a dashboard.
|
|
LOYALY_API_BASE=http://127.0.0.1:8088
|
|
|
|
# Signs the session cookie and encrypts the platform token bundle.
|
|
#
|
|
# The ONLY variable that is a real secret, and the only one production takes
|
|
# solely from the environment — it is in no committed file, by design. Set it
|
|
# as a Dokploy environment variable / secret. Locally, any string works; leave
|
|
# it blank and a development key is used.
|
|
#
|
|
# Generate with: openssl rand -hex 32 (hex, not base64 — a trailing '=' can be
|
|
# mangled by a dashboard env editor that splits on the first '=')
|
|
AUTH_SECRET=
|
|
|
|
# Browser → this app's own BFF routes. Same origin, so leave it empty. Inlined
|
|
# at BUILD time (NEXT_PUBLIC), so changing it at runtime does nothing.
|
|
NEXT_PUBLIC_API_BASE=
|