Netlify keeps searchparams when redirecting in my Next.js app

I have this simple code in my Next.js 13+ api:

NextResponse.redirect(url)

The page route looks like this:
/api/redirect/[url]?name=[somename]

The name query parameter is only used for tracking, and I do not want it to be added to the redirect. But netlify keeps it. So it redirects to

url?name=[somename]

instead of

url

This is expected. We preserve query params on redirects. You’d have to replace the query params with a different one.

Well this causes errors. I have a route that specifically redirects users to other websites, keeping the searchparams will cause errors on older websites.

How do I disable this?

How so? Could you please provide an example of an error?

No error occurs in my app.

I redirect the users to third party websites. And these websites return an error because of the searchparams. I don’t control the third party websites, but the error does not occur without the searchparams.

That’s why I want to remove them.

As mentioned before, you’d have to replace the query params with a different one for example ?redirected. Replacing with any new params should remove the old ones.