nextjs - 💡(How to fix) Fix Proxy negative matching not working when using i18n config on Vercel [4 comments, 3 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#86241Fetched 2026-04-08 02:11:58
View on GitHub
Comments
4
Participants
3
Timeline
11
Reactions
0
Author
Timeline (top)
commented ×4labeled ×2subscribed ×2cross-referenced ×1

Code Example

export const config = {
    matcher: [
        '/', 
        '/((?!api|_next/static|_next/image|login|favicon.ico|sitemap.xml|robots.txt).*)',
    ],
};

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:06 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8103
  Available memory (MB): 8192
  Available CPU cores: 8
Binaries:
  Node: 20.19.5
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.0.2-canary.23 // Latest available version is detected (16.0.2-canary.23).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

---

const nextConfig = {
    /* config options here */
    reactStrictMode: true,
    i18n: {
        locales: ['en-US', 'pt-BR'],
        defaultLocale: 'en-US',
    },
};

export default nextConfig;
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/bmamone/vercel-proxy-matcher-issue

To Reproduce

  1. Start a dev server
  2. Proxy file's negative matching works (access /login or /api/hello and check for logs. No "request" debug logs)
  3. Deploy project to Vercel
  4. Proxy file's negative matching is now ignored and causes redirect errors.

Current vs. Expected behavior

The expected is to not have any "request" debug logs on pages that should be ignored (as configured on proxy's matcher).

The proxy matcher is configured as the docs mention:

export const config = {
    matcher: [
        '/', 
        '/((?!api|_next/static|_next/image|login|favicon.ico|sitemap.xml|robots.txt).*)',
    ],
};

The expected happens when running on a local dev server. But when deployed to Vercel (production or preview) you will see the Proxy (formerly middleware) file being executed on pages that should have been ignored.

<img width="414" height="202" alt="Image" src="https://github.com/user-attachments/assets/65cb6dd3-0695-4f1b-abec-8bf31201223b" />

In the example project, this causes an infinite redirect loop issue:

<img width="1625" height="835" alt="Image" src="https://github.com/user-attachments/assets/41c22c75-69f4-4550-aa8f-f9f2afccb14a" />

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:06 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8103
  Available memory (MB): 8192
  Available CPU cores: 8
Binaries:
  Node: 20.19.5
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.0.2-canary.23 // Latest available version is detected (16.0.2-canary.23).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware, Internationalization (i18n)

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

Additional context

The bug happens as soon as i18n is setup on next.config.js and only happens when deployed to Vercel, no matter if production or preview. Could not reproduce the issue in a dev env.

Theres another issue that could be related, but was closed as completed by the original poster.

next.config.js is configured as:

const nextConfig = {
    /* config options here */
    reactStrictMode: true,
    i18n: {
        locales: ['en-US', 'pt-BR'],
        defaultLocale: 'en-US',
    },
};

export default nextConfig;

extent analysis

TL;DR

  • The issue with the proxy matcher not working as expected on Vercel deployment can be addressed by adjusting the next.config.js file to properly handle internationalization (i18n) and middleware configuration.

Guidance

  • Review the next.config.js file to ensure that the i18n configuration is correctly set up and does not interfere with the proxy matcher.
  • Verify that the middleware configuration is properly defined and exported in the next.config.js file.
  • Check the Vercel deployment configuration to ensure that it is correctly set up to handle the i18n and middleware configurations.
  • Consider testing the deployment on a preview environment before deploying to production to catch any potential issues.

Example

// next.config.js
const nextConfig = {
  // ... other configurations ...
  i18n: {
    locales: ['en-US', 'pt-BR'],
    defaultLocale: 'en-US',
  },
  // Ensure middleware is correctly configured and exported
  experimental: {
    middleware: true,
  },
};

export default nextConfig;

Notes

  • The issue seems to be related to the interaction between the i18n configuration and the proxy matcher, and adjusting the next.config.js file may resolve the issue.
  • The fact that the issue only occurs on Vercel deployment and not in the local dev environment suggests that there may be a configuration or environment-specific issue at play.

Recommendation

  • Apply workaround: Adjust the next.config.js file to properly handle i18n and middleware configurations, and test the deployment on a preview environment before deploying to production. This should help resolve the issue with the proxy matcher not working as expected on Vercel deployment.

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

nextjs - 💡(How to fix) Fix Proxy negative matching not working when using i18n config on Vercel [4 comments, 3 participants]