vercel / vercel/next.js

`next build` shows generic "Invalid segment configuration export detected" when `config.matcher` uses `String.raw` in `proxy.ts`

Open
#89,937 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Middleware Turbopack
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/ahxar/next-proxy-string-raw-repro

To Reproduce
  1. Clone the reproduction repo.
  2. Install dependencies:
    npm install
    
  3. Run:
    npm run build
    
  4. Observe this error at the end of build:
    ⨯ Invalid segment configuration export detected. This can cause unexpected behavior from the configs not being applied. You should see the relevant failures in the logs above. Please fix them to continue.
    
  5. In src/proxy.ts, remove String.raw and use a plain string literal in config.matcher.
  6. Run npm run build again and it succeeds.
Current vs. Expected behavior

Current behavior:

  • Build fails with a generic segment config error.
  • Message says "You should see the relevant failures in the logs above", but there is no actionable failure pointing to src/proxy.ts / config.matcher.

Expected behavior:

  • Error should clearly identify src/proxy.ts and explain that config.matcher must be statically analyzable (or literal), with a specific diagnostic for String.raw.
Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.28.1
Relevant Packages:
  next: 16.1.3
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Middleware

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

next build (local)

Additional context
  • Reproducible locally.
  • The issue is specifically about error reporting quality: the build failure reason is not pinpointed even though the root cause is String.raw in config.matcher inside proxy.ts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction repository's src/proxy.ts and run npm install followed by npm run build to observe the generic diagnostic. Trace the next build handling of config.matcher when it contains String.raw, then make the failure identify src/proxy.ts and explain the static-analysis requirement; done means the diagnostic is actionable and the plain-string case still builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.