`next build` shows generic "Invalid segment configuration export detected" when `config.matcher` uses `String.raw` in `proxy.ts`
Open
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
- Clone the reproduction repo.
- Install dependencies:
npm install - Run:
npm run build - 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. - In
src/proxy.ts, removeString.rawand use a plain string literal inconfig.matcher. - Run
npm run buildagain 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.tsand explain thatconfig.matchermust be statically analyzable (or literal), with a specific diagnostic forString.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.rawinconfig.matcherinsideproxy.ts.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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