use cors and better caching for assets

This commit is contained in:
hazycora 2023-12-21 10:02:37 -06:00
parent a7e9f7bee4
commit 996b596f96
No known key found for this signature in database
GPG key ID: 215AF1F81F86940E

View file

@ -47,7 +47,15 @@ async function getLanguages(owner, repo) {
return {}
}
app.use('/assets', express.static('assets'))
const assets = express.Router()
assets.use('/', (_, res, next) => {
res.set('Cache-Control', 'public, max-age=31536000')
res.set('Access-Control-Allow-Origin', '*')
next()
})
assets.use('/', express.static('assets'))
app.use('/assets', assets)
const defaultFormat = debug ? 'html' : 'png'