Skip to content

Conversation

@radding
Copy link

@radding radding commented Jan 10, 2026

There is a mismatch between next's output, and open-next's assumption.

Open Next assumes that standalone is based on the root of a monorepo, while Next uses outputFileTracingRoot to determine the root and path of .next/standalone. For example, take a monorepo like this:

apps/
  marketing/
    landing-pages/
      // next app

If you set outputFileTracingRoot in landing pages to ../, then the standalone output would be .next/standalone/landing-pages, but open-next will assume that the output is .next/standalone/apps/marketing/landing-pages.

This PR fixes that by actually looking at the standalone output and determining its structure by looking for .next/standalone/dir/.next and returning .next/standalone/dir.

I tried using the outputFileTracingRoot directly, but this proved to be more unstable because it was still tied to the relative path of the mono-repo, so in some cases it would generate wrong paths.

I also tried to set the outputFileTracingRoot in my next config to line up with what open-next assumed, and while the build was working, it bloated the assets to deploy (this mono-repo has grown a lot), which made it impossible to deploy.

@changeset-bot
Copy link

changeset-bot bot commented Jan 10, 2026

🦋 Changeset detected

Latest commit: 51fe084

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

There is a missmatch between next's output, and open-next's assumption.

Open Next assumes that standalone is based on the root of a monorepo,
while Next uses outputFileTracingRoot to determine the root and path
of .next/standalone. For example, take a monorepo like this:

apps/
  marketing/
    landing-pages/
      // next app

If you set outputFileTracingRoot in landing pages to ../, then the
standalone output would be .next/standalone/landing-pages, but
open-next will assume that the output is .next/standalone/apps/marketing/landing-pages.

This PR fixes that by actually looking at the standalone output and
determining its structure by looking for .next/standalone/dir/.next
and returning .next/standalone/dir.

I tried using the outputFileTracingRoot directly, but this proved to
be more unstable because it was still tied to the relative path of
the mono-repo, so in some cases it would generate wrong paths.

I also tried to set the outputFileTracingRoot in my next config to line
up with what open-next assumed, and while the build was working, it
bloated the assets to deploy (this mono-repo has grown a lot), which
made it impossible to deploy.
Copy link
Contributor

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one will need a bunch of testing.
I don't know which version of Next you tested against, but as a patch or a minor it has to work for Next 12 to 16. We'll drop support for 12 and 13 in the next major

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants