refactor: try fetching images (for netlify cache)

This commit is contained in:
Daniel Roe 2022-12-12 22:46:22 +00:00
parent e18443ab6f
commit 705ce6ada4
No known key found for this signature in database
GPG key ID: 22D5008E4F5D9B55
2 changed files with 5 additions and 3 deletions

View file

@ -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
: {}, : {},
}, },

View file

@ -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({