Next.js Discord

Discord Forum

Query String Begin (?) being deleted when landing on page

Answered
Paisley Terrier posted this in #help-forum
Open in Discord
Paisley TerrierOP
The query string being character (?) is being deleted when landing on a dynamic page with query parameters.

Take this example:
Before:
localhost:3000/dynamic/path?test=true

After:
localhost:3000/dynamic/pathtest=true

My page component is as follows:
export type DynamicPageProps = {
    params: {
        param: string;
    };
};

export default function DynamicPage({ params }: DynamicPageProps ) {
    return <h1>Dynamic Page {params.param}</h1>;
}


When I first land on the page, the URL is correct, but after the first react render the ? gets removed

I am using the app router, nextjs 14.2.7
Answered by Paisley Terrier
Found the issue -_-
One of my devs put a provider that redirected and did ${pathname}${queryParameters} (missing the ? inbetween)
View full answer

9 Replies

Hmm @Paisley Terrier That was not supposed to happen
Do you have any mini repo that I can reproduce the bug?
Paisley TerrierOP
I do not have a easy mini repo for you to clone, no.
I can give any details to give more context
Or you can create a new sandbox with next.js 14.2.7
and share the link, we can pair-program
Paisley TerrierOP
Found the issue -_-
One of my devs put a provider that redirected and did ${pathname}${queryParameters} (missing the ? inbetween)
Answer
Paisley TerrierOP
@James4u Thanks for the proposed help 😉
no problem. yr welcome!