Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Issue with Sanity Client Lib and SSL verification

6 replies
Last updated: Feb 17, 2023
Hello, I am having an issue the Sanity Clien Lib I think. Whenever I run the code below I get "Unhandled Runtime Error
Error: unable to get local issuer certificate " From googling it sounds like a potential is to add the
NODE_TLS_REJECT_UNAUTHORIZED
environment variable and set its value to
"0"
. But this will disable SSL verification for all requests, which is not a secure solution. I was wondering if there were any other solutions? import { previewData } from "next/headers";import { groq } from "next-sanity";
import { client } from "../../lib/sanity.client"

const query = groq`
*[_type=='post'] {
...,
author->,
categories[]->
} | order(_createdAt desc)
`;

export default async function HomePage() {
if (previewData()) {
return<div>Preview mode</div>;

}

const posts = await client.fetch(query);
console.log(posts)


return (
<div>
<h1>Not in preview mode</h1>

</div>
);
}
Feb 17, 2023, 1:38 PM
Are you on a network that’s using a firewall or proxy?
Feb 17, 2023, 4:54 PM
yes
Feb 17, 2023, 5:51 PM
That’s what’s causing your issue.
Feb 17, 2023, 5:52 PM
Ok, thanks!
Feb 17, 2023, 5:52 PM
I will speak with IT
Feb 17, 2023, 5:52 PM
Great!
Feb 17, 2023, 5:53 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?