next.js: asPath for Link - is it retired or never existed?

Bug report

Describe the bug

Below code displays /public/login on the browser. But it should be /login.

  <Link
      prefetch
      href={{ pathname: '/public/login', asPath: '/login', query: { redirectUrl } }}
  >
      <a>Log in</a>
  </Link>

To fix it, I have to use as:

  <Link
      prefetch
      href={{ pathname: '/public/login', query: { redirectUrl } }}
      as={{ pathname: '/login', query: { redirectUrl } }}
  >
      <a>Log in</a>
  </Link>

Is it understood that href object does not have asPath parameter? Was it retired or perhaps I don’t use it right? I checked type of href and do see asPath parameter. Thanks!

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

You can start app at: https://github.com/builderbook/builderbook/tree/master/book/8-end Edit code at: https://github.com/builderbook/builderbook/blob/c11f757ab5ece5bcdb67e392ec4b1dbe0a6f9620/book/8-end/components/Header.js#L90

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of Next.js: [e.g. 6.0.2]

Additional context

Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (14 by maintainers)

Most upvoted comments

@quantafire exactly why this was introduced πŸ˜„πŸ™ Glad to see it’s helping!