Skip to content

fix: output Vercel serverless function to dist/api/ to match outputDirectory - #1004

Merged
hotlong merged 2 commits into
mainfrom
copilot/fix-output-directory-mismatch
Mar 31, 2026
Merged

hotlong merged 2 commits into
mainfrom
copilot/fix-output-directory-mismatch

Conversation

Copilot AI commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

All /api/* requests on Vercel return SPA HTML instead of invoking the serverless function. bundle-api.mjs emits api/index.js at the project root, but vercel.json sets outputDirectory: "dist" — so the function is outside the deployment tree and Vercel falls back to the SPA rewrite.

Changes

  • apps/studio/scripts/bundle-api.mjsoutfile: 'api/index.js'outfile: 'dist/api/index.js'
  • apps/studio/vercel.json — Add explicit functions config declaring api/index.js with @vercel/node@3 runtime
  • apps/studio/.gitignore — Remove api/index.js / api/index.js.map entries (now under dist/, already ignored)
  • Changeset + CHANGELOG — Updated to reflect the actual root cause

@vercel

vercel Bot commented Mar 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Mar 31, 2026 4:07am
spec Ready Ready Preview, Comment Mar 31, 2026 4:07am

Request Review

…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
Copilot AI requested a review from hotlong March 31, 2026 03:50
@hotlong
hotlong marked this pull request as ready for review March 31, 2026 03:53
Copilot AI review requested due to automatic review settings March 31, 2026 03:53
@hotlong
hotlong merged commit 9f8bb6f into main Mar 31, 2026
3 of 5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js so it is included in the Vercel build output.
  • Add an explicit functions declaration in apps/studio/vercel.json for api/index.js using @vercel/node@3.
  • Remove obsolete .gitignore entries 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 thread CHANGELOG.md
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.

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.

Vercel API always returns HTML: serverless function entrypoint not found due to outputDirectory mismatch

3 participants