# BFF config — the single .env for both ways of running this app. Copy to # .env at the repo root: # cp .env.example .env # Both `cd server && npm run dev`/`npm start` (via `--env-file-if-exists=../.env`) # and `docker compose up` read this same file. Every var maps 1:1 to # server/src/config.ts. For a production-ready template, see # .env.prod.example. PORT=3000 HOST=0.0.0.0 # Upstream ContextForge/mcpgateway instance. Set this to your instance's # address; 0.0.0.0:8000 is the default local dev address. # Docker: if not on the same docker network, use the host.docker.internal # line instead. # CONTEXTFORGE_URL=http://host.docker.internal:8000 CONTEXTFORGE_URL=http://0.0.0.0:8000 # Must match mcpgateway's own AUTH_HEADER_NAME. CONTEXTFORGE_AUTH_HEADER_NAME=Authorization # Must exceed ContextForge's SMTP_TIMEOUT_SECONDS because password-reset # handlers wait for email delivery before responding. PASSWORD_RESET_REQUEST_TIMEOUT_MS=30000 # Max request body for config import (POST /api/v1/import). # Other /api/* routes keep Fastify's 1 MiB default. IMPORT_BODY_LIMIT_BYTES=10485760 # Left UNSET on purpose — behaves correctly either way this file is used: # Native: config.ts's own default applies (memory:// — in-process, # lost on restart, single-instance only, no Redis needed). # Docker: docker-compose.yml defaults REDIS_URL to its own `redis` # service, so sessions are Redis-backed automatically. # Set a value here to override either default. # REDIS_URL=redis://localhost:6379/0 # Opaque session_id -> bearer token TTL in Redis, seconds. SESSION_TTL_SECONDS=86400 # Redis key namespace. Only needs changing if multiple BFF deployments # (e.g. staging and prod) ever share one Redis instance. REDIS_KEY_PREFIX=bff # Leave unset for a host-only cookie (recommended unless the BFF and its # subdomains genuinely need to share the session cookie). COOKIE_DOMAIN= # REQUIRED false for a zero-config boot (native or Docker) — the default # (true) is for prod and fails closed on memory:// Redis and on a missing # PUBLIC_ORIGIN/TRUST_PROXY. See config.ts's two fail-closed startup checks. COOKIE_SECURE=false # Only safe behind a trusted reverse proxy that overwrites (not appends to) # X-Forwarded-For. Leave "false" for a directly-exposed BFF. TRUST_PROXY=false # Exact scheme://host the BFF is publicly reached at (e.g. # https://app.example.com), used for Origin-header validation on login, # password recovery, and SSE. # Leave unset to derive it from the request itself — fine for a # single-hostname deployment; set explicitly behind a reverse proxy where # that derivation isn't trustworthy (e.g. TLS-terminated without # TRUST_PROXY=true). PUBLIC_ORIGIN= # TLS: `npm run compose:tls` brings the stack up at https://localhost:8443 # behind a local nginx reverse proxy with a self-signed cert. That override # sets COOKIE_SECURE, TRUST_PROXY and PUBLIC_ORIGIN itself — no edits # needed here. See docs/DOCKER.md. # How often an open SSE connection re-checks Redis for session revocation, # as a fallback to the pub/sub-based instant revocation. SSE_SESSION_RECHECK_SECONDS=15 # Set to a running Vite dev server's origin to get HMR while visiting the # BFF's own port (:3000) instead of Vite's (:5173) — the BFF then proxies # everything it doesn't own (SPA shell, JS/CSS modules, HMR) to Vite. Unset # (default) = serve the built SPA from server/public/ as usual. Usually set # per-invocation instead of here — see `npm run dev:all` / `npm run dev:bff`. # VITE_DEV_SERVER_URL=http://localhost:5173 LOG_LEVEL=info # Keycloak SSO login (BFF's own OIDC client). Disabled by default -- leave # SSO_ENABLED=false to skip all of this. # # Values below match mcp-context-forge's own `make compose-sso` stack -- # both Keycloak clients ("mcp-gateway" for the gateway's own /admin UI, # "contextforge-web-ui" for this BFF) are seeded directly in that repo's # infra/keycloak/realm-export.json, no manual admin-console setup needed. # # Setting this up against a Keycloak that ISN'T mcp-context-forge's own # compose-sso stack (e.g. a real deployment)? See docs/sso-keycloak-setup.md # for client registration, the redirect-URI gotcha, and the gateway-side # trusted_for_api_auth step it also requires. SSO_ENABLED=false # SSO_KEYCLOAK_BASE_URL=http://localhost:8180 # Only needed if the browser-facing Keycloak host differs from the one above # (e.g. a Docker service name vs. a public hostname). # SSO_KEYCLOAK_PUBLIC_BASE_URL= # SSO_KEYCLOAK_REALM=mcp-gateway # SSO_KEYCLOAK_CLIENT_ID=contextforge-web-ui # SSO_KEYCLOAK_CLIENT_SECRET=contextforge-web-ui-dev-secret # SSO_KEYCLOAK_SCOPES=openid profile email # SSO_LOGIN_STATE_TTL_SECONDS=300 # SSO_TOKEN_REFRESH_LEEWAY_SECONDS=30 # Used by `npm run e2e:docker` — credentials for a real backend user the e2e # auth fixture logs in as, and docker-compose.e2e.yml's gateway admin # password — must be 22+ chars (privileged-account minimum) and not contain # the email's local part. See e2e/README.md. E2E_TEST_EMAIL= E2E_TEST_PASSWORD= # The real Keycloak SSO e2e test needs SSO_ENABLED=true in .env (the value # above is false). docker-compose.e2e.yml reads it from .env and defaults to # true only when unset. # # Optional overrides for the real Keycloak SSO e2e test -- default to the # test user seeded in e2e/keycloak/realm-export.json, so these are only # needed to log in as someone else. # E2E_SSO_USERNAME=ssotest@example.com # E2E_SSO_PASSWORD=changeme-e2e-sso