81f5ed7aa2
Fixes: #43598 This was a tricky one to find! Not sure why more people aren't complaining about this issue, was super annoying in my use case since links had the wrong URL. ## What? This issue only occurred when basepath was defined and middleware and dynamic pages are being used. Example from the reproduction repo mentioned in the issue tagged: <img width="686" alt="Screenshot 2023-04-23 at 9 32 55 PM" src="https://user-images.githubusercontent.com/11258286/233850968-e14f6b49-858b-410e-b8f9-93c90447090a.png"> ## Why? `nextConfig` wasn't passed to `getNextPathnameInfo` function, hence the basePath wasn't removed from a intermediate variable and that trickled down to cause this issue. Added test case based on the issue reproduction repo --------- Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
9 lines
226 B
JavaScript
9 lines
226 B
JavaScript
import { NextResponse } from 'next/server'
|
|
|
|
export default function middleware(_) {
|
|
const res = NextResponse.next()
|
|
res.headers.set('X-From-Middleware', 'true')
|
|
return res
|
|
}
|
|
|
|
export const config = { matcher: '/random' }
|