mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
When using both pages & app routers, during `next dev` and `next start`, if a function triggers a 404 error, we serve the app router not found page rather than the pages router one. When paired with the `i18n` configuration in `next.config`, the Next.js builder ignores the app router 404 and bundles the localized pages router 404 pages with the deployed functions. This leads to a 500 error, and is fixed in https://github.com/vercel/vercel/pull/13222 However, to match the dev/start handling, we also need to update the `pages-manifest` so the builder knows to resolve `/404.html` and not the pages router variant when deployed. Fixes NEXT-4045 Validation: [vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo](https://vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo)
40 lines
746 B
TypeScript
40 lines
746 B
TypeScript
import React from 'react'
|
|
|
|
export const getStaticProps = ({ params }: { params: { slug: string[] } }) => {
|
|
try {
|
|
const slugArray = Array.isArray(params.slug) ? params.slug : [params.slug]
|
|
|
|
const isValidPath =
|
|
slugArray.length === 1 &&
|
|
(slugArray[0] === 'about' || slugArray[0] === 'contact')
|
|
|
|
if (!isValidPath) {
|
|
return {
|
|
notFound: true,
|
|
}
|
|
}
|
|
|
|
return {
|
|
props: {
|
|
slug: params.slug,
|
|
},
|
|
}
|
|
} catch (error) {
|
|
throw error
|
|
}
|
|
}
|
|
|
|
export const getStaticPaths = async () => ({
|
|
paths: [],
|
|
fallback: 'blocking',
|
|
})
|
|
|
|
const CatchAll = () => (
|
|
<div>
|
|
<h1>Catch All</h1>
|
|
<p>This is a catch all page added to the pages router</p>
|
|
</div>
|
|
)
|
|
|
|
export default CatchAll
|