frontity: Unexpected URL should return 404 page [5pt]
Bug report
- I’ve updated both my project and my packages to the latest Frontity versions: https://docs.frontity.org/guides/keep-frontity-updated
- I’ve searched for existing issues.
- I’ve checked the documentation: https://docs.frontity.org
- I’ve checked the community forum: https://community.frontity.org
- There is a related issue (https://github.com/frontity/frontity/issues/290), closed in favor of this one.
Expected behavior
Some URL should return 404 instead of 500.
Observed behavior
My Google Search Console report that the server is return 500.

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.

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:
-
Add here a condition that would check if the fetched link and the link of the received post are the same: https://github.com/frontity/frontity/blob/107d3543ce5463186809b7e6f50ca31ffbdc107d/packages/wp-source/src/libraries/handlers/postType.ts#L38
-
Change the pattern for that handler to make it more restrictive (right now, the pattern would match almost every link) and let
actions.router.fetchto throw a 404 error when #331 has been implemented.
Thank you very much 😄
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (18 by maintainers)
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: