6f9c4720f9
## Background Currently route handlers will be attempted to statically generate the same as normal pages in app router. If a route handler accessed dynamic data such as `cookies()`, `headers()`, `req.url`, or similar we would bail from this static generation but this didn't handle the case where you would do data fetching via a non-fetch based library e.g. `redis` or even using `Date.now()` or `Math.random()` so users would expect these to be run every request like normal API endpoints but they would be static so wouldn't be executed again after a build. ## New Behavior As discussed this disable the default static generation handling for route handlers as we've seen this confuse our users since in most cases when creating a route handler you are handling dynamic workloads. This doesn't remove the ability to static generate route handlers though as you can still manually specify: If you specify `export const revalidate = 1` we will still bail if dynamic data is accessed to prevent accidental `revalidate` configuring but this can be avoided via `force-static` being used as well. ```js export const dynamic = 'force-static' // or export const dynamic = 'error' // or export const revalidate = false // or export const revalidate = 1 // value great than 0 // or export const generateStaticParams() {} ``` --------- Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com> |
||
---|---|---|
.. | ||
app | ||
test | ||
next.config.js |