@@ -85,3 +85,38 @@ import it — never instantiate a second client.
8585
8686` VITE_API_URL ` is ** required** — the dev server throws on startup without it.
8787Copy ` .env.example ` to ` .env ` and point it at your backend.
88+
89+ ---
90+
91+ ## Deployment Routing
92+
93+ The app is served under ` /aistudio/ ` (` base ` in ` vite.config.ts ` , ` basename ` in
94+ ` App.tsx ` ), but Vite emits to the deploy root — so ` vercel.json ` maps the prefixed
95+ request back onto the flat output. Rewrites are matched in order, first match wins:
96+
97+ | Rule | Purpose |
98+ | ---- | ------- |
99+ | ` /aistudio ` and ` /aistudio/ ` | serve the SPA shell |
100+ | ` /aistudio/assets/:path* ` | hashed bundles, straight through |
101+ | ` /aistudio/:file(<extensions>) ` | files copied from ` public/ ` |
102+ | ` /aistudio/:path* ` | everything else → ` index.html ` (SPA routes) |
103+
104+ The third rule lists file extensions explicitly. It previously read
105+ ` :file([^/]+\.[^/]+) ` — "any single segment containing a dot" — which is not the
106+ same question as "is this a file". Any future route with a dot in it
107+ (` /aistudio/model.compare ` , ` /aistudio/run-v1.2 ` , ` /aistudio/v2.beta ` ) matched it,
108+ got treated as a static file, and 404'd instead of reaching the SPA. The failure
109+ would appear long after the rule was written and would not look like a routing
110+ problem.
111+
112+ ` vercel.json ` must be strict JSON, so that reasoning lives here rather than inline.
113+
114+ Two consequences worth knowing before editing it:
115+
116+ - ** Adding a new file type to ` public/ ` means adding its extension here** , or the
117+ request falls through to the SPA catch-all and returns ` index.html ` with a 200 —
118+ a broken asset that does not look like a 404.
119+ - ** ` [^/]+ ` matches one segment only.** Assets in a ` public/ ` subdirectory
120+ (` public/img/logo.png ` ) are not covered by this rule and would hit the catch-all.
121+ That was true of the previous rule too; it is a known gap, not a regression. Use
122+ ` assets/ ` or the flat ` public/ ` root, or widen the pattern deliberately.
0 commit comments