question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[9.5.3 - Rewrites] Navigating route with dynamic routes no longer work properly

See original GitHub issue

Describe the bug

// 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

To Reproduce

https://codesandbox.io/s/aged-sky-nzs6j?file=/pages/index.js

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Timercommented, Sep 10, 2020

@nghiepit can you please try next@9.5.4-canary.9?

1reaction
ijjkcommented, Sep 5, 2020

@MrEfrem I opened a new issue to track the specific issue you are encountering here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic route not working on page refresh with Next.js
Since Next.js 9.5.3 there's no longer the need to use as for dynamic routes. Instead you can directly use the value to interpolate...
Read more >
Client-Side Routing In Next.js - Smashing Magazine
This article will guide you through almost everything you need to know about Routing in Next.js and point you in the direction of...
Read more >
next/router | Next.js
If cb returns false , the Next.js router will not handle popstate , and you'll be responsible for handling it in that case....
Read more >
Migrating to React Router v6: A complete guide
Migrate your React Router applications from v5 to v6 with this in-depth guide, including a review of additions and improvements from v5.
Read more >
Understanding Dynamic Routing Policies | Junos OS
The verification process required to commit configuration changes can entail a significant amount of overhead and time. For example, changing a prefix in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found