简体   繁体   中英

og:image URL error: https://mydomain/session/upload/undefined could not be processed as an image because it has an invalid content type

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?

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'}
/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM