From 996b596f9620a707205dbcfdf9a3e809ad7a15a0 Mon Sep 17 00:00:00 2001 From: hazycora Date: Thu, 21 Dec 2023 10:02:37 -0600 Subject: [PATCH] use cors and better caching for assets --- server.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 812c373..ec56160 100644 --- a/server.js +++ b/server.js @@ -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'