Files
ffd7f13c17 [Pages] fix: _error page's req.url can be overwritten to dynamic param on minimal mode (#82347)
In minimal mode, if there was `/[slug].js` with `notFound: true` on the
same segment of `_error.js`, `req.url` and `ctx.asPath` were returned as
`/[slug]`, since it was re-initialized to the request url.

Therefore, don't re-initialize the URL if it is in minimal mode && is
the `_error` page.

Fixes NEXT-4660

---------

Co-authored-by: JJ Kasper <[email protected]>
2025-08-05 20:06:32 +02:00

23 lines
338 B
TypeScript

import type { NextPageContext } from 'next'
Error.getInitialProps = (ctx: NextPageContext) => {
return {
reqUrl: ctx.req?.url,
asPath: ctx.asPath,
}
}
export default function Error({
reqUrl,
asPath,
}: {
reqUrl?: string
asPath?: string
}) {
return (
<p>
reqUrl: {reqUrl}, asPath: {asPath}
</p>
)
}