Next.js Discord

Discord Forum

URL rewriting when a query param is added to the URL

Unanswered
Motorwatch posted this in #help-forum
Open in Discord
Hi all,

I've got a really weird issue that is happening when we add a query param to the the URL

Next v12.3.4

This an old site I've inherited from a previous contractor and in the config we have the following

basePath: my-base-path

so the url would show as www.mysite.com/my-base-path/car as you'd expect

But the company's devops have got it setup that we'd only see www.mysite.com/car this url also works... fantastic!!

The problem happens when you start adding query params to the url eg if I visit the url www.mysite.com/car/?foo=bar this loads up the page, but then the url changes to www.mysite.com/my-base-path/car/?foo=bar to include the basePath, which they don't want to do.

there are no redirects (301, 302) server side, there are no rewrites, redirects in the code (Server or Browser) all I've narrowed it down to is when we disable JS the url doesn't change.

So my question is, does anything happen within NextJS that checks the URL if there is a param and then does a rewrite to include the basePath?

0 Replies