PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
17.55k stars 1.65k forks source link

Unable to set URL prefix for server API #12096

Open majikman111 opened 9 months ago

majikman111 commented 9 months ago

First check

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

mthanded commented 8 months ago

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.

tothandor commented 3 months ago

I can confirm this. Frontend assets cannot be mapped from one path to the other with proxy, no matter the PREFECT_UI_URL setting.

cicdw commented 3 months ago

We will look into this, thank you all for raising and commenting

Bear1110 commented 2 months ago

Came across this recently. After set PREFECT_UI_URL, it still does not work.

radrichard commented 3 weeks ago

Does anyone have a workaround for this? I'm pulling my hair out :)