Unable to set URL prefix for server API
First check
- [X] I added a descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I searched the Prefect documentation for this issue.
- [X] I checked that this issue is related to Prefect and not one of its dependencies.
Bug summary
I am running Prefect in a Kubernetes cluster behind an nginx reverse proxy and when setting the PREFECT_UI_SERVE_BASE setting the UI base path is updated but api base path is not, resulting in a rendered UI with no flow content. Additionally, updating the PREFECT_UI_API_URL setting changes what path the UI requests but not the path the api is actually served under.
Reproduction
1. Install Prefect
1. Apply settings `PREFECT_UI_SERVE_BASE=/root/` and `PREFECT_UI_API_URL=localhost:4200/root/api`
1. Run `prefect server start`
1. Browse to local prefect server at `localhost:4200/root`
The UI renders and api requests are sent to `localhost:4200/root/api` but fail (are being served from `localhost:4200/api`)
Error
No response
Versions
Version: 2.16.0
API version: 0.8.4
Python version: 3.11.8
Git commit: 17f42e9d
Built: Thu, Feb 22, 2024 3:45 PM
OS/Arch: linux/x86_64
Profile: default
Server type: server
Additional context
Could potentially be solved by passing a configurable root_path argument to the FastAPI api_app object if available from settings here
https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/server.py#L615
Related to #11472
Came across this recently. I'm currently rewriting prefix/api to /api using traefik rules. I agree it would be useful to have support for configuring the api to run at a path prefix too.
I can confirm this. Frontend assets cannot be mapped from one path to the other with proxy, no matter the PREFECT_UI_URL setting.
We will look into this, thank you all for raising and commenting
Came across this recently. After set PREFECT_UI_URL, it still does not work.
Does anyone have a workaround for this? I'm pulling my hair out :)
Hi guys, is this on the roadmap at all?
Hey @radrichard sorry that we ghosted this issue - I've just opened a PR that should solve this; I'd love to get some confirmation from one of you that it indeed does before releasing! You can install off my branch with pip install git+https://github.com/prefecthq/prefect.git@root-path
Hey @radrichard sorry that we ghosted this issue - I've just opened a PR that should solve this; I'd love to get some confirmation from one of you that it indeed does before releasing! You can install off my branch with
pip install git+https://github.com/prefecthq/prefect.git@root-path
Thanks so much. I'll give it a go this weekend if that's OK?
Yup that sounds good, thank you!