Skip to content

Proxy negative matching not working when using i18n config on Vercel #86241

@bmamone

Description

@bmamone

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.

Image

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

Image

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Internationalization (i18n)Related to Internationalization with Next.js.MiddlewareRelated to Next.js Middleware.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions