krasimir / navigo

A simple vanilla JavaScript router.
MIT License
2.74k stars 249 forks source link

Navigo (^8.11.1) didn't match any of the registered routes #314

Open tielebodyn opened 2 years ago

tielebodyn commented 2 years ago

hi, I seem to be having a problem with Navigo 8.11.1.

when I make a singleton of Navigo, I seem to get an error every time I set my rootURL as anything except '/'. I tried http://localhost:1234, which is definitely the correct URL for my local server, but it keeps giving me the ''didn't match any of the registered routes" warning, as you can see in the image. when I use the '/' as root URL it loads my html and JS, but still gives me the same warning (even though it clearly does match my registered route). I switched to version 7.0.0 and everything works perfectly. PS: /new-event (from console warning) is a registered route, even though you can't see it an my Index.js

ref: https://stackoverflow.com/questions/73220543/navigo-javascript-routing-every-route-i-register-didnt-match-any-of-the-regist/73302262#73302262

Router.js code:

routes

Index.js:

routes

Console warning:

Warnings
delgec commented 1 year ago

Same warning.

How can I fix this problem?

tielebodyn commented 1 year ago

@delgec I fixed it by switching to navigo 7

delgec commented 1 year ago

@delgec I fixed it by switching to navigo 7

I am also downgrade. Thanks for your reply.

ilteoood commented 1 year ago

As I can see /new-event is not a registered route. As you are using a plain string in the on function, it will match exactly that. You are trying to use the first handler, right? What if you use ':page' as route match string?

tielebodyn commented 1 year ago

@ilteoood I did infact register the new-event page. I just didn't include it in the screenshot.

ilteoood commented 1 year ago

@tielebodyn if you want to share a reproduction with stackblitz, I'm happy to help :)