Summary
The workflow bakes NEXT_PUBLIC_API_BASE_URL=https://api.cognitivemesh.io into the client bundle via Docker build-args, then promotes the same image to both staging and production. Because Next.js inlines NEXT_PUBLIC_* variables at build time, staging can never override this value at runtime and will always call the production API endpoint.
Affected file
.github/workflows/deploy-frontend.yml — lines 97-99
Required fix
Either:
- Create separate build jobs per environment, each passing environment-specific
NEXT_PUBLIC_API_BASE_URL; or
- Move API configuration to runtime (e.g., server-side config endpoint, SSR context, or non-
NEXT_PUBLIC_ env var read server-side and exposed to the client).
References