Next.js Discord

Discord Forum

Route "/[...not-found]" has a `generateViewport` that depends on Request data

Answered
Dan6erbond posted this in #help-forum
Open in Discord
Hey everyone, I'm using Next.js 15.1.1 canary and running into a very weird issue with my not-found catch-all page during the build:
Error occurred prerendering page "/[...not-found]". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Route "/[...not-found]" has a `generateViewport` that depends on Request data (`cookies()`, etc...) or external data (`fetch(...)`, etc...) but the rest of the route was static or only used cached data (`"use cache"`). If you expected this route to be prerenderable update your `generateViewport` to not use Request data and only use cached external data. Otherwise, add `await connection()` somewhere within this route to indicate explicitly it should not be prerendered.
Export encountered an error on /(frontend)/[...not-found]/page: /[...not-found], exiting the build.
 ⨯ Static worker exited with code: 1 and signal: null


The page is very simple and doesn't have any viewport nor generateViewport exports, although I did try adding it to see if that helps:
export default function NotFound() {
  return (
    <div>
      <h2>Not Found</h2>
      <p>Could not find requested resource</p>
      <Link href="/">Return Home</Link>
    </div>
  )
}
Answered by Dan6erbond
Hallelujah, thanks to the Next.js 15.2.0-canary.26 I can enable the useCache experiment instead of dynamicIO which gets rid of these errors!
View full answer

1 Reply

Hallelujah, thanks to the Next.js 15.2.0-canary.26 I can enable the useCache experiment instead of dynamicIO which gets rid of these errors!
Answer