Routes not returning URL anymore?

Hello,

I have my route resolver setup with the Client

export const Router = {
  routes: [

    {
      type: "magazin_single_post",
      path: "/:lang/blog/:category/:uid",
      resolvers: {
        category: "category",
      },
{...ETC}
    },

  ],

  href: (type) => {
    const route = Router.routes.find((r) => r.type === type);
    return route && route.href;
  },
};

export const Client = (req = null, options = {}) =>
  Prismic.client(
    apiEndpoint,
    Object.assign({ routes: Router.routes }, options)
  );

But it seems the API is not returning the url anymore and returns null

 {
    id: 'YO2cUBAAACIA0hsR',
    uid: 'welche-faktoren-beeinflussen-ihre-rente',
    url: null, // Here
    type: 'magazin_single_post',
[...]
    alternate_languages: [ [Object], [Object], [Object] ],
    data: {
[...]
    }
  },

What could be the cause?

My relevant dependencies versions:

 "@prismicio/client": "^5.1.0",
"next": "^11.1.2",
2 Likes

I have also been experiencing this issue.

@jake @DavidParys Thanks for flagging this. We're aware of this issue, and we're working on it right now. I'll let you know when I have more information.

Sam

1 Like

@jake @DavidParys Could you tell me the repository or repositories where you're having this issue? (You can send them via DM if you prefer.)

1 Like

Hi,

Thanks for your answer, I've sent you the repository name via DM

I can also confirm that past builds - I am using vercel so I can rebuild commits and branches from the past - have the same issue, which means it doesn't come from package versioning/mistake in the code.

@jake @will @DavidParys It doesn't look like a problem with the API. Could you share your project files with me so that I can try debugging? You could send me a ZIP file or invite me to a git repo (github username samlfair).

I might be onto something,

Which endpoint should be used for fetching data?

https://[repoName].prismic.io/api/v2

or

https:/[repoName].cdn.prismic.io/api/v2

Here's where the confusion comes from.

I think you may well be on to something! We're currently using (and have been using for some time without issue) the https:/[repoName].cdn.prismic.io/api/v2 version, from a quick test if we change to https:/[repoName].prismic.io/api/v2 (without cdn) the url field is returned as expected.

But as you say would be good to get clarification from @samlittlefair on which url to use, as seems like there are some implied performance benefits to using the cdn version?

1 Like

Hey @DavidParys @will,

You should definitely use the CDN. It improves response times and scalability. But it's really interesting that that makes a difference. I'll report that the dev team.

Sam

@DavidParys Does it work for you if you remove .cdn from the endpoint?

@samlittlefair Yes! Definitely, without the .cdn, the URL field is returned and works perfectly fine

This is extremely strange. We can't think of any reason why there would be a difference between the CDN and the main API. We can't reproduce the issue on our side. Could you share your project with me, so I can try to reproduce it?

Sam

It's strange indeed.

Unfortunately I wouldn't be able to share the projects' files with you as this is a company owned project.

Though I could isolate the pages in question in a separate project if that would work for you? Could also share the prismic repository as well

@DavidParys If you could create a separate project that recreates the issue, that would work for me. I've looked at the repository, and the Route Resolver works fine for me, but I'm testing it in a very different context from you.

Interesting... Ok, I will recreate the project and let you know

Thanks!

Thanks a lot, @DavidParys!

1 Like

You should have everything in your inbox :slight_smile:

Thanks, David :slight_smile: I'll take a look in the morning.

1 Like

Hello, I have the same problem since yesterday.
With .cdn in the endpoint no retrieved document seems to contain its url.
The problem must therefore come from the route resolver request: it does not return the same choice on the endpoint with .cdn and without.
This problem occurs on all my Prismic repositories.

2 Likes