Next.js Discord

Discord Forum

Middleware rewrite with dynamic routes attaching wrong query parameter in JSON call

Unanswered
Burmese posted this in #help-forum
Open in Discord
BurmeseOP
Version used next.js 13.5.2 and page router with middleware and getStaticProps. ( ISR )

Page structure used:
{
"pages": [
"/",
"/404",
"/_app",
"/_document",
"/_sites/[site]",
"/_sites/[site]/blog",
"/_sites/[site]/home",
"[locale]",
]
}

We are trying to achieve multitenancy by rewriting the path in middleware.
path: /home
rewrite path: _sites/my-site/home

When the application loads, the request made is home.json?site=my-site. However, when navigating from the home page to the blog page using router.push('/blog'), the request made is blog.json?locale=blog, which is unexpected. Despite this, the page renders correctly as _sites/my-site/blog, which is the intended outcome.

Problem: Getting blog.json?locale=blog
Expectation: blog.json or blog.json?site=my-site

Any help and suggestion would be appreciated.

0 Replies