// next.config.js
module.exports = {
rewrites() {
return [
{
source: "/my-post/:id",
destination: "/post"
}
];
}
};
Navigating via Link or router.push
<Link
href={{
pathname: "/post",
query: {
id: 1,
another: "another"
}
}}
as="/my-post/1?another=another"
>
<a>Post 1</a>
</Link>
When custom the as path with params then router.query.id no longer true.
Actual: id=1?another=another
Expected: id=1
https://codesandbox.io/s/aged-sky-nzs6j?file=/pages/index.js
I also updated and all's broken now.
Hi, you should no longer need to map the href and as manually for custom-routes and next/link as they are being resolved automatically and the above snippet works ok if you only provide the href with the destination URL e.g.
<Link href="/my-post/1?another=another">
<a>Post 1</a>
</Link>
I opened a PR to ensure this is being correctly resolved when mapping manually with href and as and automatically with only href here
This should be fixed in v9.5.4-canary.3 of Next.js please upgrade and try it out!
@ijjk I've /en/software.jsx and /en/[post].jsx files. When I navigated to /en/software/ via Router.push('/en/software/') in v9.5.2 it resolved to /en/software.jsx correctly. But in v9.5.3 and v9.5.4-canary.3 it resolves to /en/[post].jsx. Is this intentional change? And why in the minor releases do you change so things?
@MrEfrem I opened a new issue to track the specific issue you are encountering here
Hi, you should no longer need to map the
hrefandasmanually for custom-routes andnext/linkas they are being resolved automatically and the above snippet works ok if you only provide thehrefwith the destination URL e.g.<Link href="/my-post/1?another=another"> <a>Post 1</a> </Link>I had tried this, but throw error 404 and auto reload page.
Link example: https://codesandbox.io/s/hungry-breeze-675gf?file=/pages/index.js
@nghiepit can you please try [email protected]?