Next.js Discord

Discord Forum

Missing route part on client side render

Unanswered
Ant posted this in #help-forum
Open in Discord
AntOP
Hi all, Im struggling to recreate this, but have a serious problem in production :/

I have this Page:
src/app/[domain]/[[...route]]/page.tsx


I have a rewrite rule
rewrites: async () => {
    return [
        {
            source: "/:path*",
            destination: `/${process.env.DEMO_SITE}/:path*`,
        },
    ]


And when loading each page in the browser directly, everything works fine.

But when using Next/Link for client side navigation everything falls appart with this log output:

{ domain: 'nodhjelp', route: undefined }

Basically the domain is lost somewhere along the way, only when using client side routing...


Have anybody seen this before? :/

3 Replies

AntOP
Alright, I managed to recreate the issue:

https://github.com/Richard87/next-bug-rewrite
The Link is the missing link 😄 notice that when navigating to the page, the domain is changed from demo.example.com to the path "some-page"

https://next-bug-rewrite.vercel.app/