fix: detect proxy.ts correctly with compound pageExtensions#93246
Open
bmorros94 wants to merge 3 commits intovercel:canaryfrom
Open
fix: detect proxy.ts correctly with compound pageExtensions#93246bmorros94 wants to merge 3 commits intovercel:canaryfrom
bmorros94 wants to merge 3 commits intovercel:canaryfrom
Conversation
0749169 to
22512c2
Compare
When `pageExtensions` includes compound extensions like `["page.ts"]`,
the proxy file becomes `proxy.page.ts`. The existing `file_stem()` check
uses `rsplit_once('.')` which only strips the last extension, yielding
`"proxy.page"` instead of `"proxy"`, causing proxy detection to fail.
Fix: use `file_name().split('.').next()` to extract the base name before
the first dot.
Fixes vercel#85648
Ref vercel#86122
Verifies that proxy.page.ts is correctly detected and executed when pageExtensions includes compound extensions like ["page.ts"]. Ref vercel#85648 Ref vercel#86303
Apply the same fix as the Turbopack/Rust side: use split('.')[0] instead
of path.parse().name to extract the convention file basename. Handles
compound pageExtensions like 'page.ts' where proxy.page.ts yields
path.parse().name === 'proxy.page' instead of 'proxy'.
Fixes both build-time detection (build/index.ts) and dev-time detection
(setup-dev-bundler.ts).
Fixes vercel#86303
Ref vercel#86122
22512c2 to
c785334
Compare
This was referenced Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #85648
Fixes #86303
Fixes #91600
Fixes #85646
Related to #86122
Related to #92342
When
pageExtensionsis set to compound extensions like['page.ts', 'page.tsx'], proxy files must be namedproxy.page.ts. However, the proxy detection logic usedfile_stem()(Rust/Turbopack) andpath.parse().name(JS/webpack), both of which only strip the last extension — soproxy.page.tsbecomesproxy.pageinstead ofproxy, and the proxy is never detected.Root cause:
path.parse('proxy.page.ts').namereturns'proxy.page', not'proxy'. Same issue with Rust'sfile_stem()which usesrsplit_once('.').Fix: Use
file_name().split('.')[0](JS) /file_name().split('.').next()(Rust) to extract the first segment before any dot. This correctly returns'proxy'for bothproxy.tsandproxy.page.ts.The same
fileBaseNameextraction is also used formiddlewareandinstrumentationconvention file detection, fixing compound pageExtensions for those as well.Changes
crates/next-api/src/project.rs(2 locations) +crates/next-api/src/middleware.rs(1 location)packages/next/src/build/index.ts(build-time detection) +packages/next/src/server/lib/router-utils/setup-dev-bundler.ts(dev-time detection)proxy-page-extensionstest suite withpageExtensions: ['page.ts', ...]and aproxy.page.tsfixtureVerified locally
Existing proxy test suites also verified (proxy-runtime-nodejs, proxy-with-middleware, proxy-missing-export, proxy-runtime) — no regressions.
Test plan
proxy-page-extensions.test.tspasses in all 4 modes (dev/prod × turbopack/webpack)x-from-proxyheader and pages render through it