Connection issue

My front and backend have occassionally connection issues to the Prismic server. My frontend is a NextJS/React web site hosted by Vercel and my backend is Laravel/PHP hosted in AWS. I don't have detailed error codes from the frontend apart from the HTTP status 500, but the backend gave me the following error:

GuzzleHttp\Exception\ConnectException(code: 0): cURL error 35: error:0407008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding (see libcurl - Error Codes) for at /home/vagrant/code/YCRestApi/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210)

and from the Stack:

Api Request Failed {"exception":"[object] (Prismic\Exception\RequestFailureException(code: 500): Api Request Failed at /home/vagrant/code/YCRestApi/vendor/zumba/prismic-sdk/src/Prismic/Exception/RequestFailureException.php:30)

Are there any settings I can try to adjust or is this expected occassionally?


Hello @peter2, are you also using Slice Machine in this project?

yes, i do.

Hi @peter2, the first thing you need to check is if you're correctly passing your repository URL to the first API call. This is the first reason why your project may not have connection with Prismic.

Hi @Pau, you might have misunderstood me. This is not a new project and the calls to Prismic are over 99% successful. The URL is across the whole project the same env variable - as such highly unlikely that this is the cause. In any case, I retried the same api call incl the exactly same parameters and had no issues. But that shouldn't surprise you - both, backend and frontend have been making the same calls again and again - only occasionally it doesn't work.

Can you show us how you're conecting your Laravel project to Slice Machine?
For the moment the only two frameworks that have official support for Slice Machine are NextJS and NuxtJS.

Ah, yes. I forgot about that. I'm using zumba/prismic-sdk. But the issue is not with the package as I see the exact same errors and frequency in the frontend using your official package.

Besides, I have some really good use cases for using Prismic with a backend.

  • Email Marketing/Announcements are authored in the CMS and attached to all automated emails
  • Backend keeps track of readership stats for CMS authored Blogs and offers the frontend queries like for most read blogs. Naturally, the backend needs to know the status of a blog to avoid sending broken links.

I'm hoping that Prismic sooner or later will support PHP officially, but I'm not counting with it.

One of my colleagues noticed an incomplete endpoint in the error you showed us:

Therefore we deduce that it is necessary to check if the name of your repository is being added correctly everywhere. In this case, it would be necessary to add it like this:

Hi @Pau

Yes, I noticed this as well. But here is the problem. I looked into the Zumba package and as expected it makes two calls. The first one with the accessToken and the second one to retrieve the actual documents. The latter uses the ref from the first response to form the url for the second call.

I define only the URL for the first call - here is the extract (with replaced repo name):


As you can see, the first call doesn't go to your But the ref you are returning points to your cdn server. The exception happens on the second call. I verified that the Zumba package doesn't alter the ref in any way.

In my opinion therefore it seems that your server returns a ref that doesn't contain my repo name.

That would also explain why occassionally the calls in my frontend are failing - as the problem is not dependent on the package my project is using, but on the server response.

Kind Regards

What function does the Zumba package do in this case?
How does this relate to the API calls to your repository?

@Pau Sorry, took a while to have time to dig into how Prismic works.
But I don't understand your question. Zumba is doing exactly the same as your guide describes how to use prismic with Postman. The way I know your official javascript package, it follows suit.

To recap my understanding how Prismic works:

  1. client sends a GET request to "https://" + repo + "" with the access token in the header
  2. server returns in the body various information including the master ref and the url for document search (in the body under forms->everything->action)
  3. client requests a document by using the everythign action url and the master ref "<action_url>?ref=<master_ref>" + query

The action url that your server returns is the only url that includes the cdn domain. I need however to correct a sentence in my previous post. "In my opinion therefore it seems that your server returns a ref that doesn't contain my repo name." - I should say "In my opinion therefore it seems that your server returns occassionally an action url that doesn't contain the repo name."

Hey @peter2,

Would you be able to provide a screenshot of the entire response log to see how the missing repo name appears with the rest of the response?