Use static/ dir (not public/) in init templates for Vercel#50
Closed
alexkroman wants to merge 2 commits into
Closed
Use static/ dir (not public/) in init templates for Vercel#50alexkroman wants to merge 2 commits into
alexkroman wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 deployedaai inittemplate's FastAPI function tries to readpublic/index.html/public/static/*viaFileResponse/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 zerovercel.json.What changed
static/layout in all three templates:public/index.html→static/index.html,public/static/{app.js,styles.css,audio.js}→static/{...}.api/index.py(×3):PUBLIC→STATIC = ROOT / "static", mount/staticon the dir itself, plus a comment explaining why notpublic/so it isn't reverted. The/static/*URL prefix is unchanged (now maps directly to diskstatic/*).README.md,AGENTS.md): path references updated; corrected the audio-transcription deploy note (FastAPI serves the page now, not Vercel's CDN).scripts/template_contract_gate.pyand thetest_init_*suite updated for the new layout (asset-existence check now maps/static/x→static/x).Verification
scripts/template_contract_gate.py→validated 3 init templates/,/static/app.js,/static/styles.css(and/static/audio.js) with 200s🤖 Generated with Claude Code