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.

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)

  1. 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
  2. Click the “Link” or “Leading Slash” tags, notice normal behaviour.
  3. Click the “No Leading Slash” tag, notice the error for 2 seconds (how long the “page” takes to load).
  4. 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arunodacommented, Jul 24, 2017

Changed the README with this: https://github.com/zeit/next.js/commit/f8950e9b4c4c25f22047f5b019a66bf77bc1457d

I think the example as absolute URLs.

0reactions
arunodacommented, Jul 24, 2017

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.

Read more comments on GitHub >

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

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