Skip to content

Page re-export leaks server code to browser #87494

@timheerwagen

Description

@timheerwagen

Link to the code that reproduces this issue

https://github.com/timheerwagen/re-export-page-server-code-leak

To Reproduce

  1. Install dependencies and start the development server: next dev
  2. The server code for the /index page works.
  3. Navigate to /plugin-page - Server Code leaks to browser (Module not found: Can't resolve 'fs/promises')
  4. 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/A

Which 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

No one assigned

    Labels

    Pages RouterRelated to Pages Router.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions