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
22 lines
397 B
JavaScript
22 lines
397 B
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
export async function getStaticProps() {
|
|
const data = await fs.promises.readFile(
|
|
path.join(process.cwd(), 'data.txt'),
|
|
'utf8'
|
|
)
|
|
|
|
console.log('revalidate', { data })
|
|
|
|
return {
|
|
props: { data },
|
|
notFound: data.trim() === '404',
|
|
revalidate: 1,
|
|
}
|
|
}
|
|
|
|
export default function Page({ data }) {
|
|
return <p id="data">{data}</p>
|
|
}
|