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.

Incorrect router "asPath" property on server-side when trailing slashes are enabled

See original GitHub issue

Bug report

Describe the bug

When trailingSlashes: true is added to next.config.js, server-side generation does not include the trailing slash in the router asPath property.

To Reproduce

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

  1. Enable trailing slashes
  2. Add useRouter() to component
  3. Log asPath property

Expected behavior

Server-side should include a trailing slash when generating.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jleckcommented, Sep 9, 2020

Hi @tsriram, will see if I can cause this error.

0reactions
balazsorban44commented, Jan 29, 2022

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can you handle trailing slashes in next.js routes?
Basically, I mean needing to write a function somewhere to handle routing (e.g. in a server.js file), instead of just leaning next.js's native ......
Read more >
Client-Side Routing In Next.js - Smashing Magazine
Trailing Slash #​​ Both the base path and trailing slash features can only be used with Next. js 9.5 and above.
Read more >
next/router | Next.js
Learn more about the API of the Next.js Router, and access the router ... Therefore, basePath , locale and trailing slash ( trailingSlash:...
Read more >
Vert.x Web
We also ignore trailing slashes so it will be called for paths /some/path and /some/path// too: Route route = router.route().path("/some/path/"); ...
Read more >
Trailing slashes on URLs: Contentious or settled?
Relative paths are incorrect without a trailing slash. ... So as long as $PATH and $PATH/ map to the same outcome, and redirection...
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