1

Here I used to debug the above URL using Facebook sharing debugger. I have this message after debugged.

Invalid Image Content Provided og:image URL, https://mydomain/session/upload/undefined could not be processed as an image because it has an invalid content type.

I have used Next.js, and my head tag include:

<meta
    property="og:image"
    content={`${apiUrl}/session/upload/${session?.image}`}
/>

How can I solve this?

juliomalves
  • 42,130
  • 20
  • 150
  • 146
Irushan
  • 125
  • 2
  • 10
  • The fact that it's complaining about `https://mydomain/session/upload/undefined` means that `session?.image` is returning `undefined` in your code. Ensure that `session.image` is always set, or provide a different image URL when it's not. – juliomalves Jul 13 '21 at 20:27
  • This image is dynamically loaded via an API call, and I think the head tag is rendered before the API call. that's why this image returning undefined but I'm not sure what nextjs functions are being used to fix this problem. – Irushan Jul 14 '21 at 16:58

1 Answers1

1

The image path is "..../undefined", that image most likely does not exist.

Make sure ${session?.image} is not undefined. You could also use a fallback image in case it is not defined, for example:

<meta
    property="og:image"
    content={session?.image ? `${apiUrl}/session/upload/${session.image}` : 'fallback-image-url'}
/>
andyrandy
  • 72,880
  • 8
  • 113
  • 130