Skip to content

Does not work correctly when Next.js config output option is set to 'standalone' #99

@Jon1VK

Description

@Jon1VK

When running Next.js as a standalone server for example in EC2 or docker container, the Router functionality breaks.

Since Next.js is ran as a basic Node.js server in a standalone mode, the Router class is shared for each page generation. As so, the Router.getPageHref() can return wrong values in the generation phase of the page.

Here is an example, what goes wrong:

1. Page "/fi" gets revalidated
2. Page "/fi" regenaration is started
3. Router.setPageHref("/fi") is called
4. Page "/en" gets revalidated
5. Page "/en" regenaration is started
6. Router.setPageHref("/en") is called
7. Page "/fi" calls Router.getPageHref() --> returns wrong value "/en" for "/fi" page
8. Page "/fi" regeneration is finished with wrong data
9. Page "/en" regeneration is finished with correct data

Problem can be solved by removing Router.setPageHref() and Router.getPageHref() and by passing pageHref always to the OriginPage straight through props and modifying functions that use Router.getPageHref to take the pageHref as a parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions