Configuration¶
Use this guide to set ports, proxy trust, subpaths (FLUXLIT_ROOT_PATH), auth-related env vars, and project defaults in fluxlit.toml. Precedence is always: CLI flags beat environment variables; env beats the project file; then built-in defaults.
For TLS at the edge, HSTS, tightening FLUXLIT_FORWARDED_ALLOW_IPS when FLUXLIT_TRUST_PROXY is on, and CSP notes for Streamlit-heavy apps, see Production TLS and edge headers. For secrets in logs, secret managers, and JWT / OIDC rotation, see Secrets lifecycle.
Runtime-managed environment variables¶
When you use fluxlit dev or fluxlit run, the parent process sets additional FLUXLIT_* variables for the Streamlit subprocess and for code that resolves the proxy target. You typically should not override these unless you are doing advanced testing.
Variable |
Purpose |
|---|---|
|
Import target for the |
|
Public API mount path (default |
|
Absolute base URL for |
|
Base URL of the Streamlit HTTP server (loopback); used by the gateway proxy and |
|
Path to a file mirroring the upstream URL so Uvicorn reload workers and restarts stay consistent. |
create_gateway_app / bare tests may run without the upstream variables; then GET /readyz reports streamlit: not_configured. See fluxlit.runtime and Deployment.
For Pytest and in-process Streamlit AppTest patterns, including when to set
FLUXLIT_APP, FLUXLIT_TESTS, and FLUXLIT_DISABLE_URL_SESSION, see
Testing.
Precedence¶
CLI flags (highest)
Environment variables (
FLUXLIT_*, plus.envvia Pydantic Settings)Project file (
fluxlit.tomlor[tool.fluxlit]inpyproject.toml)FluxlitSettingsfield defaults
Project file¶
fluxlit.tomlin the current working directory (top-level keys), or[tool.fluxlit]inpyproject.tomliffluxlit.tomlis missing.
If both exist, fluxlit.toml wins.
Supported keys include: target, gateway_host, gateway_port, log_level, debug, api_mount_path, root_path.
Example fluxlit.toml:
target = "app:app"
gateway_host = "127.0.0.1"
gateway_port = 8000
log_level = "info"
Environment variables¶
FluxlitSettings loads FLUXLIT_* variables and optional .env.
Variable |
Role |
|---|---|
|
App title (FastAPI / UX default). |
|
When true, skip the unified-stack lifespan check that rejects Uvicorn |
|
Bind defaults (CLI still overrides for |
|
Public URL prefix when the app is mounted under a subpath (FastAPI/Uvicorn |
|
If true, enable Uvicorn |
|
Uvicorn |
|
Optional subpath used only if |
|
Set by the runtime for Streamlit-side |
|
If true, log API requests (method, path, status) at INFO with request id context. |
|
If true, enable debug mode: turns on gateway access logs and API request logging, bumps |
|
If true, log each gateway request at INFO with structured |
|
Query key used by |
|
If true, expose Prometheus text metrics on the gateway (requires |
|
HTTP GET path for metrics (default |
|
|
|
|
|
Max incoming request body bytes proxied to Streamlit; 0 = unlimited. When exceeded the gateway responds with 413. |
|
Max concurrent in-flight HTTP proxy requests to Streamlit; 0 = no limit (semaphore). |
|
When > 0, sets |
|
When max connections is set, optional keepalive cap (0 lets httpx derive). |
|
WebSocket client |
|
Optional upstream WebSocket |
|
Optional upstream |
|
Optional upstream |
|
Optional upstream |
|
JSON list of header names (e.g. |
|
If set, passed to Uvicorn |
|
If true, add baseline security headers on the FastAPI app (HSTS when HTTPS, |
|
JSON list of allowed origins (e.g. |
|
Whether to set |
|
JSON object of extra keyword arguments for Starlette |
|
JSON list of extra |
|
JSON object merged into |
|
Public origin for OAuth redirects (e.g. |
|
Compatibility fallback used only when |
|
If true, |
|
If true, constructing :class: |
|
Expected JWT |
|
HS256 secret (dev/small deploys); omit if using JWKS. |
|
JWKS URL for RS256; omit if using HS256 secret. |
|
Clock skew leeway for JWT validation (default |
|
Secret for first-party JWTs after OIDC callback; used by :meth: |
For a multi-segment mount such as /apps/my-app (nginx, FLUXLIT_PUBLIC_BASE_URL, WebSockets, and fluxlit doctor troubleshooting), see Path-prefixed mount (/apps/my-app) in Production TLS and edge headers.
Passthrough caveats: Do not use FLUXLIT_STREAMLIT_RUN_CLI_ARGS to set sidecar --server.port, --server.address, or --server.baseUrlPath (FluxLit assigns these; overrides break the parent process and gateway). In FLUXLIT_CORS_MIDDLEWARE_KWARGS, do not repeat allow_origins, allow_credentials, allow_methods, or allow_headers (FluxLit sets those from the dedicated fields; duplicates are ignored). Constructor fastapi_kwargs cannot change FastAPI title or root_path; they always follow FluxlitSettings so the API matches the public mount and Streamlit.
Gateway proxy fields also exist on FluxlitSettings as gateway_* / uvicorn_graceful_shutdown_timeout_s for use from Python (e.g. tests or FluxLit(settings=...)). JSON log formatting is not configured via env; attach JsonLogFormatter in your logging setup — see Observability.
See the fluxlit.config API reference for the full settings model.
Public URL helpers¶
Use fluxlit.app.FluxLit.urls when you need browser-visible links (Streamlit st.markdown, emails, OIDC redirects beyond the built-in BFF):
urls.app_base(request)— origin plus the public mount (FLUXLIT_ROOT_PATH/FLUXLIT_STREAMLIT_PUBLIC_PATH): where Streamlit pages live.urls.api_base(request)— app base plusFLUXLIT_API_MOUNT_PATH(default/api): whereGET /healthz,GET /readyz, OpenAPI, and Swagger UI are served on the gateway.urls.for_page/urls.page_url(request, path, query=...)— deep links under the app base (not under/api).page_urlis a readability alias for the same helper.
When FLUXLIT_PUBLIC_BASE_URL is an absolute URL with a path, that value is used as the app base (for CDNs or fixed public entrypoints). When it is origin-only (e.g. https://app.example.com), the configured public mount is appended. If it is unset or not a usable absolute URL, the current request’s scheme and host are used (respecting X-Forwarded-* when proxy trust is enabled). For invite-style links and normalized query parsing, see Deep links and query parameters.
Auth dependencies¶
Install JWT/OIDC helpers with:
pip install "fluxlit[auth]"
Core HTTP stack remains unchanged if you skip this extra.
Metrics dependencies¶
Gateway Prometheus metrics require:
pip install "fluxlit[metrics]"
If FLUXLIT_ENABLE_GATEWAY_PROMETHEUS_METRICS=1 is set without that extra,
fluxlit doctor reports fluxlit_metrics_extra with the install command.
Reverse proxies (Posit Connect, Workbench, nginx)¶
For a subpath deployment (e.g. https://server.example.com/content/123/), set FLUXLIT_ROOT_PATH to that prefix (no trailing slash), e.g. /content/123. FluxLit aligns gateway routing (whether the proxy strips the prefix or forwards the full public path) and Streamlit baseUrlPath for static assets and WebSockets. With fluxlit run, Uvicorn uses an empty root_path and the runtime injects the public mount into the ASGI scope so strip-prefix and full-path upstreams both work without doubling the prefix.
Behind a trusted edge proxy, set FLUXLIT_TRUST_PROXY=1 (or fluxlit run --proxy-headers) so scheme and host from X-Forwarded-* match what browsers use. Tighten FLUXLIT_FORWARDED_ALLOW_IPS if you do not want to trust all sources (default * when proxy trust is on and this is unset).
Set FLUXLIT_PUBLIC_BASE_URL to the public origin (e.g. https://server.example.com) when using OAuth/OIDC so redirects stay on the user-facing URL.
Note
Some platforms set a generic PUBLIC_BASE_URL. FluxLit accepts it as a fallback for
OAuth redirects, but the namespaced FLUXLIT_PUBLIC_BASE_URL wins when both are set.
Run fluxlit doctor --json in deployment CI to catch mismatches before release; add
--strict when you want obvious proxy-trust and public-URL path mistakes to FAIL
the command (see Command-line interface).
API clients in tests¶
fluxlit.client.ApiClient is for Streamlit-side server code. It reads
FLUXLIT_INTERNAL_API_BASE and defaults to http://127.0.0.1:8000/api, so paths
should be API-relative (client.get("/users"), not client.get("/api/users")).
For in-process Pytest, prefer fluxlit.testing.FluxLitTestClient; it exercises
the gateway prefix without requiring a real port. Use ApiClient in tests only when
you intentionally want to test the HTTP client wrapper itself.