Next.js Discord

Discord Forum

Can't get slug after a route rewrite

Unanswered
White-horned horntail posted this in #help-forum
Open in Discord
White-horned horntailOP
In my next.config.js, I have the following route rewrite:

async rewrites() {
return [
{
source: '/my-route/:id*',
destination: '/my-route',
},
]
}

According to the documentation here: https://nextjs.org/docs/app/api-reference/next-config-js/rewrites#rewrite-parameters, I believe I should be able to get the old :id slug as a query parameter, however I don't actually see the :id being added as a query param. Any help would be appreciated!

5 Replies

White-horned horntailOP
@joulev ahh good to know :/ thanks!
does that conflict with the documentation though? it says

module.exports = {
async rewrites() {
return [
{
source: '/old-about/:path*',
destination: '/about', // The :path parameter isn't used here so will be automatically passed in the query
},
]
},
}
White-horned horntailOP
@joulev nope, i've tried everything 🥲