mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### Why? When Proxy self-references itself, e.g., `__filename`, it is traced to the NFT file. However, since Next.js renames 'proxy.js' to 'middleware.js' during webpack build, the files in NFT will differ from the actual outputs. This can cause a problem when verifying the NFT. Current Behavior: https://github.com/vercel/next.js/actions/runs/19483162554/job/55760669267?pr=86214#step:34:91 ### How? Therefore, also rename the self-reference of `'proxy.js'` in `middleware.js.nft.json` to `'middleware.js'`. I don't expect other modules to be referencing the build output of Proxy, that is not recommended. Closes NEXT-4777 Closes NAR-518 --------- Co-authored-by: Niklas Mischkulnig <[email protected]>
18 lines
677 B
TypeScript
18 lines
677 B
TypeScript
import type { NextRequest } from 'next/server'
|
|
import { NextResponse } from 'next/server'
|
|
|
|
export default function proxy(request: NextRequest) {
|
|
if (request.nextUrl.pathname === '/home') {
|
|
return NextResponse.redirect(new URL('/', request.url))
|
|
}
|
|
|
|
// `__filename` included in the bundle makes the NFT to trace it.
|
|
// This will result creating "proxy.js" to be traced into the NFT file.
|
|
// However, as Next.js renames "proxy.js" to "middleware.js" during build,
|
|
// the files in NFT will differ from the actual outputs, which will fail for
|
|
// the providers like Vercel that checks for the files in NFT.
|
|
console.log(__filename)
|
|
|
|
return NextResponse.next()
|
|
}
|