rsnext/test/e2e/app-dir/app-routes/app
JJ Kasper 6f9c4720f9
[Breaking] Disable automatic static generation for route handlers (#65825)
## 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>
2024-05-20 16:25:02 -07:00
..
advanced Fix missing request body in DELETE and OPTIONS Route Handlers (#51874) 2023-06-27 11:44:01 +00:00
api [Breaking] Disable automatic static generation for route handlers (#65825) 2024-05-20 16:25:02 -07:00
basic Server Router Improvements (#45716) 2023-02-15 00:16:45 +00:00
conflicting-dynamic-static-segments Add dynamic parameter marker to router cache key (#47957) 2023-04-05 15:40:28 +02:00
dynamic Support force-static on App Routes (#46693) 2023-03-02 19:28:37 +00:00
edge Update app route handler proxy handling (#47088) 2023-03-13 11:34:22 -07:00
hooks Create react server condition alias for next/navigation api (#62456) 2024-02-26 13:35:44 +01:00
methods fix(route-handlers): make sure preflight has CORS headers (#63264) 2024-03-14 00:59:57 +00:00
mixed-response Loose types of app routes return value (#55849) 2023-09-25 11:34:21 +02:00
no-response Check for type of route handler returned value at build time (via the TS plugin) and at runtime (#51394) 2023-09-08 03:26:53 +00:00
revalidate-1/[slug]/data.json Ensure generateStaticParams works in route (#46310) 2023-02-23 18:33:08 +01:00
robots.txt Fix bad route path for custom metadata routes (#47286) 2023-03-21 15:55:32 +00:00
static/[slug]/data.json Ensure generateStaticParams works in route (#46310) 2023-02-23 18:33:08 +01:00
status Add ISR handling for app routes (#46133) 2023-02-21 15:25:42 -08:00
layout.tsx Add dynamic parameter marker to router cache key (#47957) 2023-04-05 15:40:28 +02:00