Can't request content via the API on our main repository

Ive spent the last few hours trying to figure out what's going on here. I have two repositories under one account - one free and one paid. The paid repo has a ton of content-type creation work that was already done.

I have been unable to migrate a front-end project to use our paid repository - I can't get any documents to load via the API from it and all in the newer free repository work fine. I even made one identical content type with the same UID and content in both, and there are no keys required for access on either. Setting the URL to the new repo in our project renders the document just fine, but changing it to use the old one doesn't work. I get the following error every time:

[next-slicezone] Error: Unexpected status code [400] on URL https://exavaultprod.cdn.prismic.io/api/v2/documents/search?routes=[{"type"%3A"page"%2C"path"%3A"%2F%3Auid"}]&page=1&pageSize=1&ref=X9wIXBEAAL4CvAIL&q=[[at(document.type%2C%20"home_page")]]

Hey @jware,

Based on the error at that URL, it looks like an error with your Link Resolver or your Route Resolver. Here are our docs on the Link Resolver:

And here's the documentation for the Route Resolver:

If you have both of those configured correctly, and it's still not working, I'll need to take a look at your project files. Could you send me a GitHub repo or a ZIP file with your project? (You can send it in a DM if you like.)

Sam

Hey Jason,

I'm still trying to figure this out. It seems like, when you add slice machine to a project, it automatically adds a Route Resolver to ~/prismic.js. That default Route Resolver include a routes array like this:

routes: [
  { type: 'page', path: '/:uid' },
],

If you set up your newer repo with Slice Machine, it would've created a page Custom Type for you in your repo. But, if you added Slice Machine to your older repo, it would not have created that Custom Type for you.

I'm checking in with my dev team, but I believe that when you query the API, Slice Machine sends that routes array to the Prismic API. If it doesn't find a matching Custom Type in your Prismic repo for a type in the array, it create an error.

Based on your error message, it looks to me like Slice Machine is indeed sending that default routes array to the API and searching for a matching page custom type. Based on the API error, it looks like it's not finding a page Custom Type, but finding these ones:

  • pricing_plan
  • blog_author
  • customer_support
  • blog_post
  • home_page
  • order_page
  • quote
  • customer
  • header
  • about_us
  • product_page
  • footer
  • landing_page

You could try deleting everything in the routes array:

export const Router = {
  routes: [],

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

Try that, and let me know if it makes a difference. In the meantime, I'll keep corresponding with our dev team to see what else could be causing the issue.

Thanks,
Sam

This issue has been closed due to inactivity. Flag to reopen.