forked from Mirrors/elk
refactor: try fetching images (for netlify cache)
This commit is contained in:
parent
e18443ab6f
commit
705ce6ada4
2 changed files with 5 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import Inspect from 'vite-plugin-inspect'
|
import Inspect from 'vite-plugin-inspect'
|
||||||
import { isCI } from 'std-env'
|
import { isCI, isDevelopment } from 'std-env'
|
||||||
import { i18n } from './config/i18n'
|
import { i18n } from './config/i18n'
|
||||||
|
|
||||||
const isPreview = process.env.PULL_REQUEST === 'true'
|
const isPreview = process.env.PULL_REQUEST === 'true'
|
||||||
|
@ -90,7 +90,7 @@ export default defineNuxtConfig({
|
||||||
routeRules: {
|
routeRules: {
|
||||||
'/api/og-image/**': {
|
'/api/og-image/**': {
|
||||||
static: isCI,
|
static: isCI,
|
||||||
cache: !isCI
|
cache: !isCI && !isDevelopment
|
||||||
? { maxAge: 86400 } // 1 day
|
? { maxAge: 86400 } // 1 day
|
||||||
: {},
|
: {},
|
||||||
},
|
},
|
||||||
|
|
|
@ -108,7 +108,9 @@ export default defineEventHandler(async (event) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await sendRedirect(event, ogImageUrl)
|
return $fetch(ogImageUrl, {
|
||||||
|
responseType: 'stream',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw createError({
|
throw createError({
|
||||||
|
|
Loading…
Reference in a new issue