Next.js Discord

Discord Forum

Rewrite to API backend

Black-headed Gull posted this in #help-forum
Open in Discord
Black-headed GullOP
I have a backend API called mits that I'm trying to redirect users to but it appears that the version=z is being stripped when I get to my mits api.

return [ { source: "/test-41.xml", destination: "/api/mits" }, { source: "/test-41-z.xml", destination: "/api/mits?version=z" } ];

In my mits api route:
const version = request.nextUrl.searchParams.get( "version" );

If I hit the api endpoint directly via http://localhost:3000/api/mits?version=z, I get the version number but not when I hit http://localhost:3000/test-41-z.xml.

How can I get the query params after the rewrite?

0 Replies