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.

Issue with notFound never triggered

See original GitHub issue

I have a simple route like:

router
  .on({
    '/product/:id': function (params) {
      renderProduct(params.id)
    },
    '/':function() {
      renderStartpage();
    }
  })
  .notFound(function() {
    pageNotFoundController();
  });

If the URL is / it will go to start page. Also if the URL is /foobar. I can never seem to be triggering the pageNotFoundController().

How should I configure my routes differently? Naturally I only want to valid routes: / and /product/XX.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
nordskillcommented, Mar 15, 2017

I guess I’ve found a workaround for this issue:

router.on(function () {
   if (window.location.pathname.length > 1) {
    console.log('404');
   } else {
    console.log('home');
   }
}).resolve();
1reaction
johnhultcommented, Mar 30, 2017

@krasimir I changed the position of the / to the end instead but nothing really changed. Said two different things in the README.md, so I thought it didn’t matter 😃 I have the latest npm version of navigo so that should be okay.

What happens is that if I go to /asdf (i.e. a non-existing route) it will just load the /asdf route as the root route instead. If I then try to navigate to for example /work, it will instead go to /asdf/work.

I was wondering if it could have something to do with my gulptask if it isn’t Navigo itself?

	gulp.task('express', function() {
		var express = require('express');
		app = express();
		app.use(historyApiFallback());
		app.use(require('connect-livereload')({port: 4001}));
		app.use(express.static(__dirname));
		app.listen(4000);
	});
Read more comments on GitHub >

github_iconTop Results From Across the Web

GetStaticProps returning initial notFound never triggers a ...
hi @ijjk we're setting revalidate: 300 if notFound: true is being returned. The problem is pretty much perfectly summarized by the original ...
Read more >
How to Fix Error 404 Not Found on Your WordPress Site - Kinsta
The Error 404 Not Found status code indicates that the origin server did not find the target resource. Check out these common causes...
Read more >
npm ERR cb() never called - node.js - Stack Overflow
I just had this exactly issue when trying to install the Sage theme for WordPress. When I ran npm install on the theme...
Read more >
Microsoft Outlook error: trigger partner failure: Unable to ...
Microsoft Outlook error: trigger partner failure: Unable to retrieve the list of calendar events: The specified object was not found in the ...
Read more >
Common errors and troubleshooting tips - IFTTT Help Center
Double-check the trigger and action fields​​ Verify that the intended Ingredients are being used where and how they should be. For example, don't ......
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