Router methods throw exception for objects with relative pathnames
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
Calling Router.push({pathname: 'about'})
should work just as <Link href={{pathname: 'about'}}/>
does, and as described here.
Current Behavior
Client side, it throws an error Route name should start with a "/", got "page"
(thrown from https://github.com/zeit/next.js/blob/v3-beta/lib/page-loader.js#L22)
It then immediately falls back to the server side route, which then loads the page as usual.
Depending on how long the server page takes to load, you may or may not see the error above.
Note that absolute pathnames (/about
) work as normal.
Steps to Reproduce (for bugs)
- https://github.com/tmeasday/next-routing-bug -
git clone https://github.com/tmeasday/next-routing-bug; cd next-routing bug; npm install; npm run dev
- Click the “Link” or “Leading Slash” tags, notice normal behaviour.
- Click the “No Leading Slash” tag, notice the error for 2 seconds (how long the “page” takes to load).
- Inspect the server console and note that the “page” page loaded from the server.
Context
I think the issue here is that the Link
calls url.resolve
here, where as Router.push
does not.
I suspect the resolve
call should come somewhere deeper in the stack.
Your Environment
Tech | Version |
---|---|
next | 2 + 3 betas |
node | 8.1.0 |
OS | macOS 10.12.5 |
browser | Chrome |
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Class: CoreRouter - Oracle
The router manages application navigation by tracking state through the browser URL. The router's core responsibility is to publish state ...
Read more >Scatter-Gather Router - MuleSoft Documentation
Configure your Scatter-Gather component to have at least two routes; otherwise, your Mule application throws an exception and does not start.
Read more >possibility to use nested routes with absolute paths ... - GitHub
I'm kinda new to React Router: there might be alternate ways of achieveing this. One of the main reasons we've got absolute routes...
Read more >URL Routing — Werkzeug Documentation (2.2.x)
The usage is simple: you just pass the match method the current path info as well as the method (which defaults to GET...
Read more >Send data through routing paths in Angular - Stack Overflow
This guide goes through various techniques about using static data in routing definition and dynamic data (state) during specific navigation. – Maciej Wojcik....
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
Changed the README with this: https://github.com/zeit/next.js/commit/f8950e9b4c4c25f22047f5b019a66bf77bc1457d
I think the example as absolute URLs.
Oh! Then we should change them. Relative URLs might work. But they cause issues (specially user space). So, that’s why don’t support it.