frontity: Unexpected URL should return 404 page [5pt]

Bug report

Expected behavior

Some URL should return 404 instead of 500.

Observed behavior

My Google Search Console report that the server is return 500.

bug

For example: https://stream-hub.com/undefined/nap-he-dieu-hanh https://stream-hub.com/kiem-tra-toc-do-mang/kiem-tra-toc-do-mang

When I run at localhost, the message is somehow unclear to me.

localhost

The actual error in development is this one:

  TypeError: Cannot read property 'split' of undefined
      at __webpack_exports__.default.str (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/utils/capitalize.ts:2:107)
      at Object.eval (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/postType.ts:10:205)
      at process._tickCallback (internal/process/next_tick.js:68:7)

The error is thrown in the following line because type is undefined: https://github.com/frontity/frontity/blob/107d3543ce5463186809b7e6f50ca31ffbdc107d/packages/wp-source/src/libraries/handlers/postType.ts#L46

Steps involved to reproduce the problem

Navigate at link http://localhost:3000/undefined/nap-he-dieu-hanh

https://gitlab.com/concalahan/stream-hub-frontity

Info about your system

Possible solution

It’s a problem in the @frontity/wp-source package, specifically in the postType handler, but it’s also happening with every handler that has a similar pattern (like for categories).

We can either:


Thank you very much 😄

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (18 by maintainers)

Most upvoted comments

I’m going to bump up the priority of this bug as it could affect the SEO and it’s happening to more users. For example -> https://community.frontity.org/t/my-personal-blog-site/1962

The only thing would be that you may want to support links with queries, in the case you added a utm campaign or something similar.

For that comparison, I would use the path from route:

const { path } = libraries.source.parse(route);

​if​ (​populated​.​length​ ​>​ ​0​ ​&&​ populated[​0​].​link​ ​===​ path) {
  isHandled ​=​ ​true​;
  ​break​;
}