Skip to content

Use static/ dir (not public/) in init templates for Vercel#50

Closed
alexkroman wants to merge 2 commits into
mainfrom
templates-static-dir-for-vercel
Closed

Use static/ dir (not public/) in init templates for Vercel#50
alexkroman wants to merge 2 commits into
mainfrom
templates-static-dir-for-vercel

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Why

Vercel treats a public/** directory specially: it auto-serves those files from its CDN and omits them from the Python function bundle. So when a deployed aai init template's FastAPI function tries to read public/index.html / public/static/* via FileResponse/StaticFiles, the files aren't in the bundle and the reads fail.

Renaming to a plain static/ dir makes the assets ship inside the function bundle, so FastAPI fully owns routing with zero vercel.json.

What changed

  • Flat static/ layout in all three templates: public/index.htmlstatic/index.html, public/static/{app.js,styles.css,audio.js}static/{...}.
  • api/index.py (×3): PUBLICSTATIC = ROOT / "static", mount /static on the dir itself, plus a comment explaining why not public/ so it isn't reverted. The /static/* URL prefix is unchanged (now maps directly to disk static/*).
  • Docs (README.md, AGENTS.md): path references updated; corrected the audio-transcription deploy note (FastAPI serves the page now, not Vercel's CDN).
  • Gate + tests: scripts/template_contract_gate.py and the test_init_* suite updated for the new layout (asset-existence check now maps /static/xstatic/x).

Verification

  • scripts/template_contract_gate.pyvalidated 3 init templates
  • 86 init/scaffold/template tests pass
  • ruff / prettier / markdownlint clean
  • TestClient run confirms all three apps serve /, /static/app.js, /static/styles.css (and /static/audio.js) with 200s

🤖 Generated with Claude Code

alexkroman-assembly and others added 2 commits June 9, 2026 10:52
Vercel auto-serves a `public/**` directory from its CDN and omits it from the
Python function bundle, so a deployed template's FastAPI `FileResponse` /
`StaticFiles` reads could fail. Move each template's front-end assets into a
flat `static/` dir that ships inside the function bundle, letting FastAPI own
all routing with zero `vercel.json`.

- public/index.html -> static/index.html; public/static/{app.js,styles.css,
  audio.js} -> static/{...} across all three templates.
- api/index.py: PUBLIC -> STATIC, mount /static on the dir itself, with a
  comment explaining why not public/ so it isn't reverted.
- README/AGENTS docs and the contract gate + init tests updated; the
  /static/* URL now maps directly to disk static/*.

Verified: contract gate passes, 86 init tests pass, ruff/prettier/markdownlint
clean, and a TestClient run confirms all three apps serve / and /static/*.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alexkroman alexkroman closed this Jun 9, 2026
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.

2 participants