Next.js middleware fails to execute after Vercel CLI 50.28.0 build regression

Problem

My Next.js 14.2.35 middleware stopped executing on production. After extensive debugging, I traced it to a regression in Vercel CLI 50.28.0.

Evidence

I have two deployments of the exact same commit (d14ff83):

  • Original build (Vercel CLI 50.27.1) → middleware works perfectly
  • Fresh rebuild (Vercel CLI 50.28.0) → middleware never executes

Both builds are identical — same Next.js version (14.2.35), same ƒ Middleware 49.8 kB in build output, same routes, same everything. The only difference is the Vercel CLI version.

Symptoms

  • Middleware compiles successfully and appears in deployment summary under “Routing Middleware” with correct matcher
  • But it never executes at runtime — no headers set, no logs, no side effects
  • Middleware does NOT appear in the deployment Functions tab (no Edge function listed)
  • Even a minimal 5-line middleware (just sets one header, zero dependencies) doesn’t execute
  • Fails on both custom domains and .vercel.app URL
  • Clean redeploy without build cache doesn’t help
  • Tried VERCEL_CLI_VERSION=50.27.1 env var but the version isn’t available on the registry

Middleware location: src/middleware.ts (also tested at project root — same result)

Workaround

Promoting the old deployment built with CLI 50.27.1 restores functionality.

Environment

  • Framework: Next.js 14.2.35 (App Router)
  • Plan: Hobby
  • Structure: src/ directory

Is this a known regression in CLI 50.28.0? Is there a way to pin the build CLI version to 50.27.1?

1 Like

Hey @garymast, welcome to the community!

Thanks for the detailed information, have passed this onto the CLI team to check out.

Same problems on my side. Seems that 50.28.0 broke something with the middleware. My multi-tenants app is not redirecting the users to their own sub-domains.

Same issue here. Next.js 15.5.12 with next-intl middleware (localePrefix: ‘as-needed’). All new deployments since
March 6 ignore middleware.ts — unprefixed routes 404 while /en/* works. Vercel AI support confirmed
NEXT_ENABLE_ADAPTER is being injected by the platform, causing Next.js 16 proxy.ts behavior on a Next.js 15 project.
Production site is down. Vercel CLI 50.28.0, Node 24.x.

Same issue, but on 15.5.9 I’m getting this error from clerk

Clerk: auth() was called but Clerk can’t detect usage of clerkMiddleware(). Please ensure the following:

Your Middleware exists at ./middleware.(ts|js)

clerkMiddleware() is used in your Next.js Middleware.

Your Middleware matcher is configured to match this route or page.

If you are using the src directory, make sure the Middleware file is inside of it.

For more details, see https://clerk.com/err/auth-middleware

Thanks all, raising with relevant teams!

same here!

I just quickly migrated out of vercel, all production was down.

I will monitor this, move back when it’s fixed

same here. all rewrites in middlewear not working

Thank you everyone for sharing, the team is actively looking into this - will post when I have further updates.

1 Like

looks like I have this issue too.

I am not using the Vercel CLI… just pushing to GitHub… and observe that my middleware seems out of order in the recent deployments…

The Vercel Help bot found that between my working deployments (yesterday) and today’s an env variable was added: VERCEL_SKIP_EDGE_FUNCTION_ENDPOINT
No idea if it’s related or not…

Next.js Middleware fails on Edge Runtime but works with runtime: 'nodejs' on Vercel.

I’m experiencing an issue where Next.js Middleware (middleware.ts) does not execute at all when deployed to Vercel using the default Edge Runtime. However, adding export const runtime = 'nodejs' makes it work correctly.

Environment

  • Framework: Next.js 15.5.9 (App Router)
  • Deployment: Vercel (Production & Preview)
  • Dependencies: @clerk/nextjs 6.36.5, but issue persists even with minimal middleware
  • Local dev: Works fine with Edge Runtime (next dev)

Configuration

// middleware.ts (Edge - NOT working on Vercel)
import { clerkMiddleware } from '@clerk/nextjs/server'
export default clerkMiddleware()
export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}
// middleware.ts (Node.js - WORKING on Vercel)
export const runtime = 'nodejs' // Adding this fixes it
import { clerkMiddleware } from '@clerk/nextjs/server'
export default clerkMiddleware()

Observed Behavior

  • With default Edge Runtime: Middleware never executes (no logs in Vercel Function Logs).
  • Error: auth() throws:

“can’t detect usage of clerkMiddleware()”
(because the middleware chain is broken).

  • With runtime = 'nodejs': Middleware executes correctly on every matched request.

Steps Tried

  1. Simplified matcher to catch-all patterns
  2. Cleared Vercel build cache & redeployed
  3. Upgraded to latest Next.js and @clerk/nextjs versions
  4. Verified file location (src/middleware.ts at project root level)

Expected Behavior

Edge Runtime should work as documented for Middleware, or documentation should clarify when Node.js runtime is required.

Additional Context

Issue appears specific to Vercel build environment; local next dev works fine with Edge Runtime.

Team is actively investigating, status page here: Vercel Status - Elevated Errors on Middleware Invocations

Edit: incident resolved.

1 Like

Same here.

The issue is not about CLI 50.28.0.

This deployment work fine, pls check the log.

Running build in Washington, D.C., USA (East) – iad1
Build machine configuration: 2 cores, 8 GB
Cloning github.com/RCFans/StrategyLogic (Branch: main, Commit: 8a6fc5f)
Cloning completed: 1.806s
Restored build cache from previous deployment (DQrH1rmBSHDcQhpyaYjNHWWAEPRd)
Running "vercel build"
Vercel CLI 50.28.0
Detected `pnpm-lock.yaml` 9 which may be generated by pnpm@9.x or pnpm@10.x
Using pnpm@9.x based on project creation date

deployment link is below, if you can visit.

https://vercel.com/strategylogic/platform/4kzdVAaqeMz4cs7tWMD414fsGnAh

Same here, this is is crashing our site. I was able to promote a previous deployment from a few hours ago and that has at least brought the site back up.
Strangely, that deployment also use CLI 50.28.0 about 5 hours ago and succeeded. Everything after that suffered the issue discussed here - no middleware invocation whatsoever.

Also for future reference, I checked the Vercel status page frequently over the past hour and there was no mention of this - would have been nice to at least have some mention of an investigation instead of me debugging alone, diagnosing the issue, then doing a general search to find this community thread.

2 Likes

Welcome to the community, feel free to make posts in the future so you don’t have to debug alone :slight_smile: But yeah, heard. Appreciate the feedback, Dalyan! :folded_hands:

2 Likes

Rollback has resolved the issue for now.

We recommend redeploying, more to follow.

Appreciate your patience everyone!

1 Like