First call when showing a post returns 404

Hi again guys,

I am having some problems trying to fix a 404 that we get on our frontity blog.
The problems goes like this:
If you enter: https://www.crowdfarming.com/es/blog/ everything goes smooth, you can navigate without a problem and there is no error on the console, but if you go to directly to a post (https://www.crowdfarming.com/es/blog/2020/12/01/el-challenge-de-las-clementinas-de-pau-gasol-se-hace-viral/), the first thing you get is a 404. It is not a problem as the page loads as normal, but it is for SEO.

The error I get con the console

{ ServerError: post type from endpoints "pages" with slug "el-challenge-de-las-clementinas-de-pau-gasol-se-hace-viral" not found
    at Object.Jr [as func] (D:\home\site\wwwroot\blog\build\server.js:244:109729)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'ServerError',
  status: 404,
  statusText:
   'post type from endpoints "pages" with slug "el-challenge-de-las-clementinas-de-pau-gasol-se-hace-viral" not found' }

I don’t know exactly where endpoint pages comes from as I haven’t declare it.
Shouldn’t the slug be /2020/12/01/el-challenge-de-las-clementinas-de-pau-gasol-se-hace-viral/ ?
As I understand it, this seems like I have a “pages” endpoint where the data with this slug should be populated, and when tries to find it, it returns a 404.

This are my settings for dev:

{
  "name": "my-app-es",
  "mode": "default",
  "match":["\/es\/blog"],
  "packages": [
    {
      "name": "@cf/cf-theme",
      "state": {
        "theme": {
          "subdirectory": "/es/blog/",
          "lang": "es",
          config,
        },
      }
    },
    {
      "name": "@frontity/wp-source",
      "state": {
        "source": {
          "api": "https://public-api.wordpress.com/wp/v2/sites/crowdfarminges.news.blog/",
          "subdirectory": "/es/blog",
          "url": "https://public-api.wordpress.com/wp/v2/sites/crowdfarminges.news.blog/"
// url was not before, just trying things
        },
      }
    },
    "@frontity/tiny-router",
    "@frontity/html2react"
  ]
}

Also, this problem only occur on production, while it does not happen on local. I thought this could be related with the SSR, but I don’t see anything strange on the before/after:
BeforeSSR:

const before = async ({ state, libraries }) => {
await staticData.func({ route: '/static-data/', state, libraries });
};

AfterCSR: it loads GTM.

If you can throw any light to this problem I would appreciate it a lot, this is breaking my head.

@David Can you help here?
I’m not sure what may be happening here

Taking a look at the issue right now.

@g.rabello, @juanma I’ll let you know if I find something.

@g.rabello, just looking at the production version it’s hard to debug, but I guess it should be related to the handlers you have. Seems that the one being executed for the link /es/blog/2020/12/01/el-challenge-de-las-clementinas-de-pau-gasol-se-hace-viral/ is the last one, which is not for posts but for pages. That should be the reason it’s using the pages endpoint.

It’s not clear for me why is that happening. As you are using the subdirectory /es/blog/, the final link /2020/12/01/el-challenge-[…] should match the post handler. I’ll try to reproduce the problem locally, with a similar configuration.

Stay tuned.

@g.rabello one question: when you say that, do you mean the production bundle or the production environment?

If it’s the production environment, it might be related to the nodejs version. Which version do you have in production?

I did another tests and I’m pretty sure the problem is somehow related to the node server.

When you run frontity.actions.source.fetch() with force: true in the browser, the post handler matches, and the data is correctly populated in the store.

Screenshot from 2021-02-17 15-05-38