Update Sentry Example Page (auto-added in CLI) to work with cache components
dymanic is not allowed with cache components and currently our added example page throws this error:
./app/api/sentry-example-api/route.ts:2:14
Error: Route segment config "dynamic" is not compatible with `nextConfig.cacheComponents`. Please remove it.
1 | import * as Sentry from "@sentry/nextjs";
> 2 | export const dynamic = "force-dynamic";
| ^^^^^^^
3 |
4 | class SentryExampleAPIError extends Error {
5 | constructor(message: string | undefined) {
Ecmascript file had an error
at <unknown> (./app/api/sentry-example-api/route.ts:2:14)
[ELIFECYCLE] Command failed with exit code 1.
@s1gr1d, for #24200 I would make the generated example a four-case compatibility fixture rather than checking only that the dynamic export disappeared: cacheComponents on/off × example route before/after the change. The cache-on/current-template cell should reproduce the reported build error; the changed template should build in both configurations, while keeping the example's intended request-time error behavior.
Concrete first step: generate the route into an isolated minimal Next.js app for each cache configuration, remove the incompatible route-segment dynamic export in the proposed template, run the build, and request the example endpoint twice using a valid synthetic DSN and local Sentry transport stub. An independent handler counter must show two distinct executions, each reaching the intended error path; no event may leave the local test. Preserve the exact Next.js and generator versions in the fixture; a text/AST assertion alone cannot establish caching behavior or a successful build.
This is a free proposed regression recipe. I have not built these Next.js fixtures or verified the generator change, and no real DSN or customer app is required. AI-assisted technical contribution, reviewed before sharing.