SkepTiz
SkepTiz

Reputation: 11

Next/Image show error "unable to verify the first certificate on next image" - NextJS

so, basicly i fetched public api that have ssl error, and i fixed it with this line of variable.

Agent({
    rejectUnauthorized: false,
    keepAlive: false,)}

but when i try to fetch image data with Next/Image it wont show up. I opened up the console it says Failed to load resource:

the server responded with a status of 500 (Internal Server Error)

then i try to click the img url, its showing an error, it says

FetchError: request to https://cdn01.site.com.... failed, reason: unable to verify the first certificate

and finally i use html img tag, and it perfectly fine. Is there any possible ways to use Next/image for this problem?

Upvotes: 1

Views: 1356

Answers (1)

yassire mtioui
yassire mtioui

Reputation: 41

You can fix it by overriding the default loader

const myLoader = ({ src, width, quality }) => {
 return `${src}?w=${width}&q=${quality || 75}`
}

and

<Image
  loader={myLoader}
  src={imageUrl}
  alt="Picture of the author"
  width={500}
  height={500}
/>

Upvotes: 3

Related Questions