-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Open
Labels
Pages RouterRelated to Pages Router.Related to Pages Router.
Description
Link to the code that reproduces this issue
https://github.com/timheerwagen/re-export-page-server-code-leak
To Reproduce
- Install dependencies and start the development server:
next dev - The server code for the
/indexpage works. - Navigate to
/plugin-page- Server Code leaks to browser (Module not found: Can't resolve 'fs/promises') - Navigate to
/component-page- Server Code leaks to browser (Module not found: Can't resolve 'fs/promises')
Current vs. Expected behavior
Only the getServerSideProps function in the pages directory works with server code.
Re-exporting a page, whether within the same application package or an external/workspace package (e.g. plugin), leaks server code to the browser.
The docs state a fix, which has already been used to reproduce the issue: https://nextjs.org/docs/messages/export-all-in-page#possible-ways-to-fix-it (export { default, getServerSideProps } from "@repo/page-plugin/pages/index"; )
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Home
Available memory (MB): 16294
Available CPU cores: 12
Binaries:
Node: 24.11.1
npm: 11.6.2
Yarn: N/A
pnpm: 9.0.0
Relevant Packages:
next: 16.1.0 // Latest available version is detected (16.1.0).
eslint-config-next: N/A
react: 19.2.3
react-dom: 19.2.3
typescript: N/A
Next.js Config:
output: N/AWhich area(s) are affected? (Select all that apply)
Pages Router
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
Metadata
Metadata
Assignees
Labels
Pages RouterRelated to Pages Router.Related to Pages Router.