Skip to content

Enhance experience for developing static site #7336

@raymondsze

Description

@raymondsze

Feature request

Create an environment variable to always remove the req and res object inside ctx.

Is your feature request related to a problem? Please describe.

Next.js is great for building SSR site. But Next.js is great for building static site with export command.
The export command works after build.
The building process could be slow and that is production build which is hard to debug.
When we do export, the req and res are disappeared (Which is true for static web).
When we are development static site, we normally use next dev, and the ctx comes with req and res. If I mistakenly used them, export command would throw error.

Describe the solution you'd like

So what I propose is an environment flag or something inside next.config.js to enforce removal of req and res of ctx object to prevent mistake when building static site. It could be also a "switch" from SSR to Static mode, or vice versa.

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions