fix: output Vercel serverless function to dist/api/ to match outputDirectory - #1004
Merged
Merged
Conversation
3 tasks
|
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>
Copilot
AI
changed the title
[WIP] Fix output directory mismatch for Vercel API functions
fix: output Vercel serverless function to dist/api/ to match outputDirectory
Mar 31, 2026
hotlong
marked this pull request as ready for review
March 31, 2026 03:53
Contributor
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). |
Comment on lines
+42
to
+47
| ### 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.
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.
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)