mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
The problem is that the adapter expected a `output.pages` for the `/404` route so that it can add these files to other Pages handlers so that they can render a 404 at runtime (getStaticProps with revaliate/getServerSideProps): https://github.com/nextjs/adapter-vercel/blob/650effd340b4f676a9bca6e0cdaba9bf7d34595a/packages/adapter/src/outputs.ts#L421-L438 https://github.com/nextjs/adapter-vercel/blob/650effd340b4f676a9bca6e0cdaba9bf7d34595a/packages/adapter/src/node-handler.ts#L331-L340 But this 404 Pages handler was not actually emitted if it was prerendered, where it only emitted the `/404.html` static file. But that's not what the adapter needs. Tests: 1. Run as an e2e test 2. Add a variant with dynamically rendered 404 pages Full e2e test run: ~~https://github.com/vercel/next.js/actions/runs/29081105397~~ https://github.com/vercel/next.js/actions/runs/29087851475 Closes NEXT-4947
50 lines
918 B
JavaScript
50 lines
918 B
JavaScript
import path from 'path'
|
|
import fs from 'fs-extra'
|
|
|
|
export default function Page(props) {
|
|
return (
|
|
<>
|
|
<p id="fallback-blocking">fallback blocking page</p>
|
|
<p id="props">{JSON.stringify(props)}</p>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const getStaticProps = async ({ params }) => {
|
|
const { slug } = params
|
|
|
|
if (!slug) {
|
|
throw new Error(`missing slug value for /fallback-true/[slug]`)
|
|
}
|
|
|
|
const dir = path.join(process.cwd(), '.tmp/fallback-blocking', slug)
|
|
|
|
if (await fs.exists(dir)) {
|
|
return {
|
|
props: {
|
|
params,
|
|
found: true,
|
|
hello: 'world',
|
|
random: Math.random(),
|
|
},
|
|
revalidate: 1,
|
|
}
|
|
}
|
|
|
|
await fs.ensureDir(dir)
|
|
|
|
return {
|
|
notFound: true,
|
|
revalidate: 1,
|
|
}
|
|
}
|
|
|
|
export const getStaticPaths = async () => {
|
|
await fs.remove(path.join(process.cwd(), '.tmp/fallback-blocking'))
|
|
|
|
return {
|
|
paths: [],
|
|
fallback: 'blocking',
|
|
}
|
|
}
|