forked from Mirrors/elk
Only request opengraph if api key is defined
This commit is contained in:
parent
2c3e0253f6
commit
a4eae9891b
1 changed files with 6 additions and 4 deletions
|
@ -40,11 +40,13 @@ export default defineEventHandler(async (event) => {
|
|||
const html = await $fetch<string>(cardUrl)
|
||||
ogImageUrl = extractOgImageUrl(html)
|
||||
|
||||
// If no og:image was found, try to get it from opengraph.io
|
||||
if (!ogImageUrl) {
|
||||
const response = await getOpenGraphClient().getSiteInfo(cardUrl)
|
||||
if (process.env.NUXT_OPENGRAPH_API) {
|
||||
// If no og:image was found, try to get it from opengraph.io
|
||||
if (!ogImageUrl) {
|
||||
const response = await getOpenGraphClient().getSiteInfo(cardUrl)
|
||||
|
||||
ogImageUrl = response?.openGraph?.image?.url ?? ''
|
||||
ogImageUrl = response?.openGraph?.image?.url ?? ''
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
|
|
Loading…
Reference in a new issue