Skip to content

Fix duplicate /api route handling#15297

Merged
jeffsee55 merged 7 commits intomainfrom
jeffsee/cli-152-dynamic-routes-with-id-segments-return-404-on-vercel-despite
Mar 2, 2026
Merged

Fix duplicate /api route handling#15297
jeffsee55 merged 7 commits intomainfrom
jeffsee/cli-152-dynamic-routes-with-id-segments-return-404-on-vercel-despite

Conversation

@jeffsee55
Copy link
Contributor

@jeffsee55 jeffsee55 commented Feb 27, 2026

Fix dynamic routes with [id] segments returning 404 on Vercel . When Next.js is the frontend, do not add the catch-all ^/api(/.*)?$ → 404 rewrite, so App Router API routes like /api/blog/posts/[id] are handled by Next.js instead of being 404'd by zero-config routes.

Can be reproduced by deploying this repo and visiting /api/flow/hello/next, which incorrectly 404s.

Warning

High Risk Change

Changes routing logic in detect-builders.ts to skip adding catch-all 404 rewrite for /api routes when Next.js is the frontend, which alters request handling behavior in production deployments.

  • Routing: conditionally skips catch-all /api 404 rewrite when Next.js detected
  • Infrastructure: affects how Vercel routes API requests in production
  • Tests added to verify behavior for both Next.js and non-Next.js frontends

Risk assessment for commit a18f5c3.

…2). When Next.js is the frontend, do not add the catch-all `^/api(/.*)?$` → 404 rewrite, so App Router API routes like `/api/blog/posts/[id]` are handled by Next.js instead of being 404'd by zero-config routes.
@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: a18f5c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@vercel/fs-detectors Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

📦 CLI Tarball Ready

The Vercel CLI tarball for this PR is now available!

Quick Test

You can test this PR's CLI directly by running:

npx https://vercel-2qo53qp1p.vercel.sh/tarballs/vercel.tgz --help

Use in vercel.json

To use this CLI version in your project builds, add to your vercel.json:

{
  "build": {
    "env": {
      "VERCEL_CLI_VERSION": "vercel@https://vercel-2qo53qp1p.vercel.sh/tarballs/vercel.tgz"
    }
  }
}

Python Runtime Wheel

A vercel-runtime wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_RUNTIME_PYTHON="vercel-runtime @ https://vercel-2qo53qp1p.vercel.sh/tarballs/vercel_runtime-0.6.0.dev1772252471+a18f5c3-py3-none-any.whl"

Python Workers Wheel

A vercel-workers wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_WORKERS_PYTHON="vercel-workers @ https://vercel-2qo53qp1p.vercel.sh/tarballs/vercel_workers-0.1.0.dev1772252471+a18f5c3-py3-none-any.whl"

@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

🧪 Unit Test Strategy

Comparing: 0c4ebf1a18f5c3 (view diff)

Strategy: Affected packages only

✅ Only testing packages that have been modified or depend on modified packages.

Affected packages - 3 (8%)
  1. @vercel/fs-detectors
  2. @vercel/static-build
  3. vercel
Unaffected packages - 37 (93%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/build-utils
  4. @vercel/cervel
  5. @vercel/cli-auth
  6. @vercel/client
  7. @vercel/config
  8. @vercel/detect-agent
  9. @vercel/edge
  10. @vercel/elysia
  11. @vercel/error-utils
  12. @vercel/express
  13. @vercel/fastify
  14. @vercel/firewall
  15. @vercel/frameworks
  16. @vercel/functions
  17. @vercel/gatsby-plugin-vercel-builder
  18. @vercel/go
  19. @vercel/h3
  20. @vercel/hono
  21. @vercel/hydrogen
  22. @vercel/koa
  23. @vercel/nestjs
  24. @vercel/next
  25. @vercel/node
  26. @vercel/oidc
  27. @vercel/oidc-aws-credentials-provider
  28. @vercel/python
  29. @vercel/python-analysis
  30. @vercel/redwood
  31. @vercel/related-projects
  32. @vercel/remix-builder
  33. @vercel/routing-utils
  34. @vercel/ruby
  35. @vercel/rust
  36. @vercel/static-config
  37. examples

Results

  • Unit tests: Only affected packages will run unit tests
  • E2E tests: Running in parallel via E2E Tests workflow
  • Type checks: Only affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

@jeffsee55 jeffsee55 marked this pull request as ready for review February 27, 2026 23:23
@jeffsee55 jeffsee55 requested review from a team and agadzik as code owners February 27, 2026 23:23
@jeffsee55 jeffsee55 requested a review from ijjk February 27, 2026 23:25
Removed filter for experimental fixture '06-services-multi-frontend-multi-runtime'.
@jeffsee55 jeffsee55 merged commit f1e8c97 into main Mar 2, 2026
270 of 274 checks passed
@jeffsee55 jeffsee55 deleted the jeffsee/cli-152-dynamic-routes-with-id-segments-return-404-on-vercel-despite branch March 2, 2026 18:35
jeffsee55 pushed a commit that referenced this pull request Mar 2, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/backends@0.0.40

### Patch Changes

- Updated dependencies
\[[`9721f4948a72d273f792c54f5393aa50ac279209`](9721f49)]:
    -   @vercel/build-utils@13.6.2

## @vercel/build-utils@13.6.2

### Patch Changes

- add partialFallback flag to prerender output
([#14703](#14703))

## @vercel/cervel@0.0.27

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/backends@0.0.40

## vercel@50.25.6

### Patch Changes

- Updated dependencies
\[[`9721f4948a72d273f792c54f5393aa50ac279209`](9721f49)]:
    -   @vercel/build-utils@13.6.2
    -   @vercel/next@4.15.37
    -   @vercel/backends@0.0.40
    -   @vercel/elysia@0.1.43
    -   @vercel/express@0.1.52
    -   @vercel/fastify@0.1.46
    -   @vercel/go@3.4.3
    -   @vercel/h3@0.1.52
    -   @vercel/hono@0.2.46
    -   @vercel/hydrogen@1.3.5
    -   @vercel/koa@0.1.26
    -   @vercel/nestjs@0.2.47
    -   @vercel/node@5.6.10
    -   @vercel/python@6.19.0
    -   @vercel/redwood@2.4.9
    -   @vercel/remix-builder@5.6.0
    -   @vercel/ruby@2.3.2
    -   @vercel/rust@1.0.5
    -   @vercel/static-build@2.8.44

## @vercel/client@17.2.51

### Patch Changes

- Updated dependencies
\[[`9721f4948a72d273f792c54f5393aa50ac279209`](9721f49)]:
    -   @vercel/build-utils@13.6.2

## @vercel/elysia@0.1.43

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.10

## @vercel/express@0.1.52

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.10
    -   @vercel/cervel@0.0.27

## @vercel/fastify@0.1.46

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.10

## @vercel/fs-detectors@5.8.15

### Patch Changes

- Fix App Router dynamic API routes returning 404 in production. When a
project has both Next.js (App Router) and a root `api/` folder,
zero-config added a catch-all `^/api(/.*)?# @vercel/fs-detectors → 404
in the filesystem phase, which runs before the rewrite phase where
Next.js routes live. So requests like
`/api/flow/hello/next`or`/api/blog/posts/5`matched the catch-all and
never reached the Next.js route. When Next.js is the frontend we no
longer add that rewrite so those routes are handled by Next.js.
(Locally, only`next dev`worked;`vc dev\` had the same 404.)
([#15297](#15297))

## @vercel/gatsby-plugin-vercel-builder@2.0.142

### Patch Changes

- Updated dependencies
\[[`9721f4948a72d273f792c54f5393aa50ac279209`](9721f49)]:
    -   @vercel/build-utils@13.6.2

## @vercel/h3@0.1.52

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.10

## @vercel/hono@0.2.46

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.10

## @vercel/koa@0.1.26

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.10

## @vercel/nestjs@0.2.47

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.10

## @vercel/next@4.15.37

### Patch Changes

- add partialFallback flag to prerender output
([#14703](#14703))

## @vercel/node@5.6.10

### Patch Changes

- Updated dependencies
\[[`9721f4948a72d273f792c54f5393aa50ac279209`](9721f49)]:
    -   @vercel/build-utils@13.6.2

## @vercel/static-build@2.8.44

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.142


<!-- VADE_RISK_START -->
> [!NOTE]
> Low Risk Change
>
> This PR is an automated Changesets release that only bumps version
numbers in package.json files and updates CHANGELOG.md files across
multiple packages, with no code logic changes.
> 
> - Version bumps in package.json files (patch versions)
> - CHANGELOG.md updates documenting dependency updates
> - Deleted changeset markdown files consumed by release process
>
> <sup>Risk assessment for [commit
00d9965](https://github.com/vercel/vercel/commit/00d9965d12c097c2375af4e717f17594ca2ed06c).</sup>
<!-- VADE_RISK_END -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants