nextjs - 💡(How to fix) Fix App Router API routes hang indefinitely on Vercel — Next.js 16.1.6, monorepo [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#91431Fetched 2026-04-08 02:02:01
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
closed ×1commented ×1labeled ×1locked ×1

All App Router API routes (route handlers) hang indefinitely on Vercel, returning - status in runtime logs and eventually 504 Gateway Timeout. SSR/SSG pages work perfectly (200). This has been the case since the project was created — API routes have never worked.

Error Message

TimeMethodPathStatus
00:40:10GET/api/ping-
00:36:51GET/api/ping404
21:32:55GET/api/health-
21:30:25GET/api/podcast/feed-
21:25:48GET/api/podcast/feed504
21:26:24GET/api/inngest504

Root Cause

All App Router API routes (route handlers) hang indefinitely on Vercel, returning - status in runtime logs and eventually 504 Gateway Timeout. SSR/SSG pages work perfectly (200). This has been the case since the project was created — API routes have never worked.

Code Example

// apps/web/src/app/api/ping/route.ts
export async function GET() {
  return new Response(JSON.stringify({ pong: true, ts: Date.now() }), {
    status: 200,
    headers: { "Content-Type": "application/json" },
  });
}

---

| Time     | Method | Path              | Status |
|----------|--------|-------------------|--------|
| 00:40:10 | GET    | /api/ping         | -      |
| 00:36:51 | GET    | /api/ping         | 404    |  ← old deployment (route didn't exist yet)
| 21:32:55 | GET    | /api/health       | -      |
| 21:30:25 | GET    | /api/podcast/feed | -      |
| 21:25:48 | GET    | /api/podcast/feed | 504    | error: Unhandled Rejection
| 21:26:24 | GET    | /api/inngest      | 504    | error

---

@tee/web:build: ├ ƒ /api/health
@tee/web:build: ├ ƒ /api/ping
@tee/web:build: ├ ƒ /api/podcast/feed
@tee/web:build: ├ ƒ /api/inngest

---

tee-monorepo/
├── apps/
│   └── web/Vercel Root Directory
│       └── src/
│           └── app/
│               └── api/
│                   ├── ping/route.ts     ← zero-import test
│                   ├── health/route.ts
│                   └── podcast/feed/route.ts
├── packages/         ← shared packages
├── package.json      ← workspaces root
└── turbo.json
RAW_BUFFERClick to expand / collapse

Description

All App Router API routes (route handlers) hang indefinitely on Vercel, returning - status in runtime logs and eventually 504 Gateway Timeout. SSR/SSG pages work perfectly (200). This has been the case since the project was created — API routes have never worked.

Environment

  • Next.js: 16.1.6
  • Framework: App Router (no Pages Router)
  • Bundler: Turbopack (default) — also tested with webpack (--webpack), same result
  • Hosting: Vercel Pro plan
  • Node.js: Tested both 20.x and 24.x — same result
  • Monorepo: pnpm 10 workspaces + Turborepo
  • Vercel Root Directory: apps/web (subdirectory of monorepo)
  • Project ID: prj_m2u41b4wqSnv7A7GbE5J1fxNE6kA

Minimal reproduction

The simplest possible API route hangs:

// apps/web/src/app/api/ping/route.ts
export async function GET() {
  return new Response(JSON.stringify({ pong: true, ts: Date.now() }), {
    status: 200,
    headers: { "Content-Type": "application/json" },
  });
}

Zero imports, zero external calls, zero dependencies. This route returns - (no status) in Vercel runtime logs and eventually 504s.

What works vs. what doesn't

Request typeStatusNotes
Pages (SSR)✅ 200/, /stories, /thrusts, /pricing, etc. all work
Static assets✅ 200CSS, JS, images all work
API routes❌ hangs/504ALL routes including zero-import /api/ping

What we've tested (exhaustive)

We systematically eliminated every possible code-level cause:

  1. Deleted proxy.ts entirely (no middleware at all) — still hangs
  2. Zero-import API route (/api/ping) — still hangs
  3. Node.js 24.x → 20.x — still hangs
  4. Turbopack → webpack (next build --webpack) — still hangs
  5. Disabled Vercel Deployment Protection — still hangs
  6. Approved pnpm native build scripts (pnpm.onlyBuiltDependencies) — still hangs
  7. Removed Clerk middleware — still hangs
  8. Simplified proxy.ts to bare NextResponse.next() — still hangs

Vercel runtime logs

Production runtime logs show all API routes with - status (no response) or 504:

| Time     | Method | Path              | Status |
|----------|--------|-------------------|--------|
| 00:40:10 | GET    | /api/ping         | -      |
| 00:36:51 | GET    | /api/ping         | 404    |  ← old deployment (route didn't exist yet)
| 21:32:55 | GET    | /api/health       | -      |
| 21:30:25 | GET    | /api/podcast/feed | -      |
| 21:25:48 | GET    | /api/podcast/feed | 504    | error: Unhandled Rejection
| 21:26:24 | GET    | /api/inngest      | 504    | error

Meanwhile, all page routes return 200 on the same deployment.

Build output

The build succeeds and shows API routes as ƒ (dynamic serverless functions):

@tee/web:build: ├ ƒ /api/health
@tee/web:build: ├ ƒ /api/ping
@tee/web:build: ├ ƒ /api/podcast/feed
@tee/web:build: ├ ƒ /api/inngest

Functions are compiled but never execute successfully at runtime.

Monorepo structure

tee-monorepo/
├── apps/
│   └── web/          ← Vercel Root Directory
│       └── src/
│           └── app/
│               └── api/
│                   ├── ping/route.ts     ← zero-import test
│                   ├── health/route.ts
│                   └── podcast/feed/route.ts
├── packages/         ← shared packages
├── package.json      ← workspaces root
└── turbo.json

Hypothesis

The issue may be related to how Vercel deploys serverless functions from a monorepo subdirectory with Next.js 16. Since pages (SSR) work but API routes (serverless functions) don't, the function invocation path appears broken. The functions are created during build but fail during runtime initialization before any user code executes.

Related

extent analysis

TL;DR

The most likely fix involves reconfiguring the Vercel deployment settings to correctly handle serverless functions from a monorepo subdirectory with Next.js 16.

Guidance

  1. Verify Vercel Configuration: Ensure that the Vercel configuration is set up to handle serverless functions from a monorepo subdirectory. This may involve updating the vercel.json file to specify the correct root directory and serverless function configuration.
  2. Check Serverless Function Invocation: Investigate how Vercel invokes serverless functions from a monorepo subdirectory. This may involve checking the Vercel documentation or seeking support from Vercel to ensure that the invocation path is correctly configured.
  3. Test with a Simple Serverless Function: Create a simple serverless function outside of the monorepo structure to test if the issue is specific to the monorepo setup or a more general problem with serverless function deployment on Vercel.
  4. Review Vercel Deployment Logs: Carefully review the Vercel deployment logs to identify any errors or warnings that may indicate a configuration issue or other problem with the deployment process.

Example

No specific code example is provided as the issue appears to be related to the Vercel configuration and deployment process rather than a code-level problem.

Notes

The issue may be specific to the combination of Next.js 16, Vercel, and a monorepo structure. Further investigation and testing are needed to determine the root cause and develop a definitive solution.

Recommendation

Apply a workaround by reconfiguring the Vercel deployment settings to correctly handle serverless functions from a monorepo subdirectory. This may involve updating the vercel.json file or seeking support from Vercel to ensure that the invocation path is correctly configured.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING