Incorrect router "asPath" property on server-side when trailing slashes are enabled
See original GitHub issueBug 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:
- Enable trailing slashes
- Add
useRouter()
to component - Log
asPath
property
Expected behavior
Server-side should include a trailing slash when generating.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @tsriram, will see if I can cause this error.
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.