Files
Hendrik LiebauandGitHub bb41cbd6ee Apply server actions transform to node_modules in route handlers (#89316)
The server actions transform, which handles the `'use cache'` directive,
was not being applied to `node_modules` when imported from route
handlers. This caused `'use cache'` functions from dependencies to fail
with errors like `"cacheLife() can only be called inside a 'use cache'
function"``.

The issue was that the `AppRoute` context used `internal_custom_rules`
for its foreign code module options, which did not include the server
actions transform. This is inconsistent with `AppRSC` (App Router
pages), which correctly uses `foreign_next_server_rules` that includes
the transform.

The fix extends `foreign_next_server_rules` with `internal_custom_rules`
and uses it for the foreign code context in `AppRoute`, matching the
pattern used by `AppRSC`.
2026-01-31 00:03:29 +01:00

16 lines
368 B
TypeScript

import { getCachedRandomWithCacheLife } from 'my-pkg'
import { NextRequest } from 'next/server'
export async function generateStaticParams() {
return [{ id: await getCachedRandomWithCacheLife() }]
}
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params
return Response.json({ id })
}