Skip to content

fix(api): serve SPA when installed via pip#16

Open
pritambiswal wants to merge 1 commit into
OpenAEC-Foundation:mainfrom
pritambiswal:fix/static-dir-after-pip-install
Open

fix(api): serve SPA when installed via pip#16
pritambiswal wants to merge 1 commit into
OpenAEC-Foundation:mainfrom
pritambiswal:fix/static-dir-after-pip-install

Conversation

@pritambiswal

Copy link
Copy Markdown
Collaborator

After pip install ., api.py runs from site-packages so Path(__file__).parent.parent.parent / "static" no longer points at /app/static. The mount silently no-ops and every non-API URL returns FastAPI's default 404.

Adds an OPENAEC_STATIC_DIR env override (Dockerfile pins it to /app/static), falls back to the old relative path so in-place dev runs still work.

After `pip install .` api.py runs from site-packages, so
Path(__file__).parent.parent.parent / "static" resolves to
<site-packages parent>/static (e.g. /usr/local/lib/python3.12/static)
which doesn't exist. The Dockerfile copies the built frontend to
/app/static, so the StaticFiles mount silently no-ops and every
non-API URL returns FastAPI's default {"detail": "Not Found"}.

Honour an OPENAEC_STATIC_DIR env override and fall back to the old
source-tree-relative path so `python -m uvicorn` from the repo root
still works in dev. Dockerfile pins it to /app/static.
@pritambiswal
pritambiswal requested a review from jochem25 as a code owner May 29, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant