feat: add backend_path config to prefix backend routes#6338
feat: add backend_path config to prefix backend routes#6338FarhanAliRaza wants to merge 4 commits intoreflex-dev:mainfrom
Conversation
Mirrors frontend_path: sets a URL prefix (e.g. "/api") applied to every backend endpoint (event websocket, /ping, /_upload, /_health, /_all_routes) and automatically included in URLs baked into the frontend via Endpoint.get_url(). Enables proxying Reflex behind a subpath without request rewriting or baking the prefix into api_url.
Greptile SummaryThis PR adds a Confidence Score: 5/5Safe to merge; all remaining findings are style-level P2 suggestions. The feature is correctly implemented end-to-end: Minor: Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[rxconfig.py\nbackend_path = '/api'] --> B[Config.prepend_backend_path]
B --> C1[app.py: _setup_state\nmount '/_event' → '/api/_event']
B --> C2[app.py: _add_default_endpoints\n/ping → /api/ping\n/_health → /api/_health]
B --> C3[app.py: _add_optional_endpoints\n/_upload → /api/_upload]
B --> C4[app.py: add_all_routes_endpoint\n/_all_routes → /api/_all_routes]
B --> C5[Endpoint.get_url\nreturns api_url + /api/endpoint]
C5 --> D[set_env_json\nbakes prefixed URLs into env.json]
D --> E[Frontend JS\nreads env.EVENT / env.UPLOAD\nconnects to /api/_event]
C1 & C2 & C3 & C4 --> F[Starlette routes\nmounted at prefixed paths]
E -->|WebSocket| F
Reviews (1): Last reviewed commit: "feat: add backend_path config to prefix ..." | Re-trigger Greptile |
Mirrors frontend_path: sets a URL prefix (e.g. "/api") applied to every backend endpoint (event websocket, /ping, /_upload, /_health, /_all_routes) and automatically included in URLs baked into the frontend via Endpoint.get_url(). Enables proxying Reflex behind a subpath without request rewriting or baking the prefix into api_url.
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features:
closes #6305