cloudflare / cloudflare/vinext

[nextjs-tracker] Pages Router files named sitemap/robots/icon/etc. must not be validated as App Router entries

Open
#2,923 0 comments 0 reactions 0 assignees View on GitHub
nextjs-tracking
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

## Next.js change

Next.js scoped its App Router file-convention export validation to files that live **inside** the app directory. Previously the SWC RSC validator matched App Router conventions (`page`, `layout`, `route`, `sitemap`, `robots`, `manifest`, `icon`, `opengraph-image`, etc.) purely by filename, so a Pages Router file like `pages/sitemap.js` or `pages/robots.js` that exported `getStaticProps`/`getServerSideProps` incorrectly failed the build with `"getStaticProps" is not supported in app/.` (regression introduced in 16.3.0 by #94962). The fix gates all App-entry checks (and the client-import error message) on a new `is_in_app_dir()` helper, and also fixes the client-import "server-only API" message to distinguish Pages vs Client Component context.

**Commits:** [cdf5c37](https://github.com/vercel/next.js/commit/cdf5c37d8499fb42ad3bae429fd456a1e256e6e6)
**Next.js files changed:** `crates/next-custom-transforms/src/transforms/react_server_components.rs`, `test/e2e/pages-app-router-filenames/`

## Why this matters to vinext

vinext scans both `pages/` and `app/` and applies its own routing + convention detection (`packages/vinext/src/routing/pages-router.ts`, `packages/vinext/src/routing/app-router.ts`). If vinext treats a file named `sitemap`/`robots`/`manifest`/`icon`/`opengraph-image`/`twitter-image` as a metadata/App Router convention based on filename alone, it will mis-handle those files when they live under `pages/` — where they are ordinary Pages routes (`pages/sitemap.js` is a page, not a metadata route). App Router metadata-convention handling and any export-validation must be gated on the file being inside the app directory.

## Priority

**Important**

## Suggested action

- Investigate: confirm whether vinext's `pages/` scanner or metadata-convention detection matches `sitemap`/`robots`/`manifest`/`icon`/`opengraph-image`/`twitter-image` by basename regardless of directory. If so, gate that detection on the app directory (mirror `is_in_app_dir`) so Pages Router files with those names are treated as normal pages and may export `getStaticProps`/`getServerSideProps`. Add a fixture with `pages/sitemap.js` + `getStaticProps`.

Contributor guide

Open the contributing guide

Research direction

Start in packages/vinext/src/routing/pages-router.ts and packages/vinext/src/routing/app-router.ts, and check whether metadata conventions are matched by basename without considering the directory. Add a fixture with pages/sitemap.js exporting getStaticProps. Done means Pages Router files named sitemap, robots, manifest, icon, opengraph-image, or twitter-image remain ordinary pages while App Router conventions still work under app/.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.