Uh oh!
There was an error while loading. Please reload this page.
fix: output Vercel serverless function to dist/api/ to match outputDirectory - #1004
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…outputDirectory The bundle-api.mjs script was emitting api/index.js at the project root, but vercel.json sets outputDirectory: "dist" — so Vercel could not discover the serverless function and fell back to the SPA HTML route for all /api/* requests. - Change esbuild outfile from api/index.js to dist/api/index.js - Add explicit functions config in vercel.json with @vercel/node@3 runtime - Remove obsolete .gitignore entries for api/index.js (now under dist/) - Update changeset and CHANGELOG Fixes#1002 Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/24bf6f10-3ca1-4cff-a9cb-c6c0905d1845 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
Fixes Studio’s Vercel deployment so /api/* requests invoke the bundled serverless function instead of falling back to the SPA HTML, by ensuring the function entrypoint is emitted inside the configured Vercel outputDirectory.
Changes:
- Update the API bundle output path to
dist/api/index.jsso it is included in the Vercel build output. - Add an explicit
functionsdeclaration inapps/studio/vercel.jsonforapi/index.jsusing@vercel/node@3. - Remove obsolete
.gitignoreentries for the old non-dist/API bundle location; update changeset + root changelog to reflect the real root cause.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| CHANGELOG.md | Documents the Vercel API HTML fallback root cause and the corrective deployment changes. |
| apps/studio/vercel.json | Ensures Vercel recognizes the serverless function under the dist/ output via explicit functions config. |
| apps/studio/scripts/bundle-api.mjs | Emits the bundled serverless function into dist/api/index.js to match outputDirectory. |
| apps/studio/.gitignore | Removes ignores for the old api/index.js(.map) location now that output is under dist/. |
| .changeset/fix-vercel-api-html-response.md | Updates the release note to match the actual cause and fix (output location + functions config). |
| ### Fixed | ||
| - **Vercel API always returns HTML — serverless function entrypoint not found** — The `bundle-api.mjs` | ||
| script was emitting `api/index.js` at the project root, but `vercel.json` sets `outputDirectory: "dist"`, | ||
| so Vercel could not discover the serverless function and fell back to the SPA HTML route for all | ||
| `/api/*` requests. Changed esbuild `outfile` to `dist/api/index.js` and added explicit `functions` | ||
| config in `vercel.json` with `@vercel/node@3` runtime. |
There was a problem hiding this comment.
There are now two separate ### Fixed sections under the [Unreleased] heading (this one and another later in the same section). Consider moving this new bullet into the existing [Unreleased]### Fixed section to keep the changelog structure consistent and easier to scan.
All
/api/*requests on Vercel return SPA HTML instead of invoking the serverless function.bundle-api.mjsemitsapi/index.jsat the project root, butvercel.jsonsetsoutputDirectory: "dist"— so the function is outside the deployment tree and Vercel falls back to the SPA rewrite.Changes
apps/studio/scripts/bundle-api.mjs—outfile: 'api/index.js'→outfile: 'dist/api/index.js'apps/studio/vercel.json— Add explicitfunctionsconfig declaringapi/index.jswith@vercel/node@3runtimeapps/studio/.gitignore— Removeapi/index.js/api/index.js.mapentries (now underdist/, already ignored)