Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
proxy.ts does not execute in production when behind Cloudflare Proxy (middleware.ts works) | GoodFirstPicks

proxy.ts does not execute in production when behind Cloudflare Proxy (middleware.ts works)

vercel/next.js 58 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

The issue involves Cloudflare Proxy integration and runtime environment differences.

AI Summary

The issue reports that `proxy.ts` does not execute when deployed behind Cloudflare Proxy, while `middleware.ts` works fine. The problem seems to be related to the runtime environment or Cloudflare integration. The maintainer has suggested checking the runtime configuration, but the exact cause is still unclear.

Issue Description

Link to the code that reproduces this issue

https://github.com/shivaluma/report-bug-next16-proxy https://github.com/shivaluma/report-bug-next16-proxy/tree/middleware

To Reproduce

To Reproduce

  1. Create a new Next.js project (or use any existing Next.js 16.0.3 project):
npx create-next-app@latest
  1. At the project root, create a file named middleware.ts:
// middleware.ts
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";

export function middleware(req: NextRequest) {
  console.log("MIDDLEWARE RUNNING:", req.nextUrl.pathname);
  return NextResponse.next();
}

export const config = {
  matcher: ["/(.*)"],
};
  1. Deploy the project behind Cloudflare Proxy enabled (Cloudflare orange-cloud ON → proxied traffic).

  2. Visit any route (e.g., /). You will see the expected log output: MIDDLEWARE RUNNING: /

  3. Now rename the file from middleware.ts → proxy.ts, and update the function name:

// proxy.ts
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";

export function proxy(req: NextRequest) {
  console.log("PROXY RUNNING:", req.nextUrl.pathname);
  return NextResponse.next();
}

export const config = {
  matcher: ["/(.*)"],
};
  1. Remove the old middleware.ts file. Ensure only proxy.ts exists in the project root.

  2. Redeploy behind Cloudflare Proxy enabled.

  3. Visit any route again.


Actual Result

  • No logs appear.
  • The proxy.ts file does not execute at all.
  • Requests behave as if no middleware/proxy file exists.

Expected Result

proxy.ts should execute exactly like middleware.ts, with identical config and behavior, including when Cloudflare Proxy is turned on.

Configuration Usage: output: "standalone"

Current vs. Expected behavior

Current Behavior

  • When using middleware.ts, the middleware executes correctly in:

    • local developm

GitHub Labels

Runtime

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • Cloudflare Proxy integration
  • runtime environment
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno