Skip to content
GitHub

Configuration

All web configuration lives under the web key in application.yaml. The provider auto-injects the typed WebConfig — no manual loading needed.

Env prefix: LEX_WEB__ | Nested delimiter: __

web:
enabled: true
env: development
server:
host: 0.0.0.0
port: 8000
workers: 1
reload: false
debug: false
openapi_title: "My API"
openapi_version: "1.0.0"
Terminal window
export LEX_WEB__SERVER__HOST=0.0.0.0
export LEX_WEB__SERVER__PORT=8080

KeyTypeDefaultEnv VarDescription
enabledboolTrueLEX_WEB__ENABLEDEnable the web module
envstr | NoneNoneLEX_WEB__ENVEnvironment name (development/staging/production)
openapi_titlestr"API"LEX_WEB__OPENAPI_TITLEOpenAPI title
openapi_versionstr"1.0.0"LEX_WEB__OPENAPI_VERSIONOpenAPI version
openapi_urlstr | None"/openapi.json"LEX_WEB__OPENAPI_URLOpenAPI schema path
swagger_ui_urlstr | None"/docs"LEX_WEB__SWAGGER_UI_URLSwagger UI path
redoc_urlstr | None"/redoc"LEX_WEB__REDOC_URLReDoc path
compression_enabledboolTrueLEX_WEB__COMPRESSION_ENABLEDEnable response compression
template_directorystr"templates"LEX_WEB__TEMPLATE_DIRECTORYJinja2 template directory
debug_routesboolFalseLEX_WEB__DEBUG_ROUTESEnable /debug/* endpoints
debug_routes_tokenSecretStr | NoneNoneLEX_WEB__DEBUG_ROUTES_TOKENToken for debug routes (X-Debug-Token header)
enable_authboolFalseLEX_WEB__ENABLE_AUTHEnable built-in auth middleware
enable_identity_resolutionboolFalseLEX_WEB__ENABLE_IDENTITY_RESOLUTIONResolve OAuth external IDs
max_body_sizeint | None10485760 (10 MiB)LEX_WEB__MAX_BODY_SIZEMax request body size (None = disabled)
auth_exclude_pathslist[str]["/health", "/health/", "/docs", "/redoc", "/openapi.json"]LEX_WEB__AUTH_EXCLUDE_PATHSPaths excluded from auth

KeyTypeDefaultEnv VarDescription
hoststr"127.0.0.1"LEX_WEB__SERVER__HOSTBind host
portint8000LEX_WEB__SERVER__PORTBind port
workersint1LEX_WEB__SERVER__WORKERSNumber of workers
reloadboolFalseLEX_WEB__SERVER__RELOADEnable auto-reload
debugboolFalseLEX_WEB__SERVER__DEBUGEnable debug mode

KeyTypeDefaultEnv VarDescription
enabledboolTrueLEX_WEB__RATE_LIMIT__ENABLEDEnable rate limiting
default_limitint100LEX_WEB__RATE_LIMIT__DEFAULT_LIMITMax requests per window
default_windowint60LEX_WEB__RATE_LIMIT__DEFAULT_WINDOWWindow in seconds
whitelist_ipslist[str][]LEX_WEB__RATE_LIMIT__WHITELIST_IPSExempt IPs
storage_backendstr"memory"LEX_WEB__RATE_LIMIT__STORAGE_BACKENDBackend (memory/redis)

Per-path rules in rules:

web:
rate_limit:
rules:
"/api/auth/login":
requests: 10
window: 60
"/api/health":
requests: 1000
window: 60

KeyTypeDefaultEnv VarDescription
enabledboolFalseLEX_WEB__STATIC__ENABLEDEnable static file serving
directorystr"static"LEX_WEB__STATIC__DIRECTORYDirectory to serve
prefixstr"/static"LEX_WEB__STATIC__PREFIXURL prefix
htmlboolFalseLEX_WEB__STATIC__HTMLServe HTML (SPA mode)

KeyTypeDefaultEnv VarDescription
enabledboolFalseLEX_WEB__API_DOCS__ENABLEDEnable API docs endpoints
providerstr"both"LEX_WEB__API_DOCS__PROVIDER”swagger”, “redoc”, or “both”

KeyTypeDefaultEnv VarDescription
allowed_originslist[str]["http://localhost:3000", "http://localhost:8001"]LEX_WEB__CORS__ALLOWED_ORIGINSAllowed origins
allow_methodslist[str]["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]LEX_WEB__CORS__ALLOW_METHODSAllowed HTTP methods

In production, LEX_WEB__CORS__ALLOWED_ORIGINS must be set to specific origins — wildcard * is rejected with a validation error.


Sub-keys: security.csrf, security.headers, security.hsts, security.csp, security.cross_origin. Import the typed configs from lexigram.web.security.config for full field listings.

web:
security:
csrf:
enabled: true
excluded_paths: ["/api/", "/health", "/metrics"]
hsts:
max_age: 31536000
include_subdomains: true

application.yaml
web:
enabled: true
env: development
server:
host: 0.0.0.0
port: 8000
reload: true
cors:
allowed_origins:
- "http://localhost:3000"
rate_limit:
enabled: true
default_limit: 200
default_window: 60
openapi_title: "My API"
openapi_version: "0.1.0"

Environment override equivalent:

Terminal window
export LEX_WEB__SERVER__HOST=0.0.0.0
export LEX_WEB__SERVER__PORT=8080
export LEX_WEB__CORS__ALLOWED_ORIGINS='["https://myapp.com"]'
export LEX_WEB__RATE_LIMIT__DEFAULT_LIMIT=500