Verify storage files before serving from the index, disable CDN caching on image 404/403 and host-isolation blocks, and retry gallery thumbnails after transient load failures.
11 lines
452 B
TypeScript
11 lines
452 B
TypeScript
import { shouldBlockImageHostRequest, shouldBlockSiteHostImageRequest } from '../utils/host-isolation'
|
|
|
|
const HOST_ISOLATION_CACHE_CONTROL = 'private, no-cache, max-age=0'
|
|
|
|
export default defineEventHandler((event) => {
|
|
if (shouldBlockImageHostRequest(event) || shouldBlockSiteHostImageRequest(event)) {
|
|
setHeader(event, 'Cache-Control', HOST_ISOLATION_CACHE_CONTROL)
|
|
throw createError({ statusCode: 404, statusMessage: 'Not Found' })
|
|
}
|
|
})
|