Behind a Proxy
root_path
Section titled “root_path”When running behind a proxy, set root_path so JustAPI knows the external path:
app = JustAPIApp(root_path="/api/v1")Nginx Configuration
Section titled “Nginx Configuration”location /api/ { proxy_pass http://localhost:8000/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;}Cloudflare
Section titled “Cloudflare”Cloudflare automatically adds the right headers. JustAPI detects them:
app = JustAPIApp(root_path="/")Trusted Hosts with Proxy
Section titled “Trusted Hosts with Proxy”from starlette.middleware.trustedhost import TrustedHostMiddleware
app.add_middleware( TrustedHostMiddleware, allowed_hosts=["example.com", "*.example.com"],)See Also
Section titled “See Also”- Docker — containerized deployment
- Kubernetes / Helm — K8s deployment
- Production Checklist — production setup