23 lines
689 B
TypeScript
23 lines
689 B
TypeScript
import {
|
|
shouldBlockImageHostRequest,
|
|
shouldBlockVideoHostRequest,
|
|
shouldBlockFileHostRequest,
|
|
shouldBlockSiteHostImageRequest,
|
|
shouldBlockUnknownHostRequest
|
|
} from '../utils/host-isolation'
|
|
|
|
const HOST_ISOLATION_CACHE_CONTROL = 'private, no-cache, max-age=0'
|
|
|
|
export default defineEventHandler((event) => {
|
|
if (
|
|
shouldBlockUnknownHostRequest(event)
|
|
|| shouldBlockImageHostRequest(event)
|
|
|| shouldBlockVideoHostRequest(event)
|
|
|| shouldBlockFileHostRequest(event)
|
|
|| shouldBlockSiteHostImageRequest(event)
|
|
) {
|
|
setHeader(event, 'Cache-Control', HOST_ISOLATION_CACHE_CONTROL)
|
|
throw createError({ statusCode: 404, statusMessage: 'Not Found' })
|
|
}
|
|
})
|