Separate runtime manifest inputs from directly served files
This commit is contained in:
@@ -2498,12 +2498,12 @@ app.get('/index.html', indexHtml);
|
||||
// current body with no-store, never immutable caching under a mismatched URL.
|
||||
app.get('/*', async (c, next) => {
|
||||
const p = decodeURIComponent(new URL(c.req.url).pathname);
|
||||
if (p.includes('..') || p.startsWith('/api/') || !assets.manifest.files[p]) return next();
|
||||
if (p.includes('..') || p.startsWith('/api/') || !assets.deliveryFiles[p]) return next();
|
||||
const file = Bun.file('./public' + p);
|
||||
const raw = assets.bytes.get(p);
|
||||
const ext = p.slice(p.lastIndexOf('.') + 1).toLowerCase();
|
||||
const hash = assets.manifest.files[p].h;
|
||||
const cacheControl = assetCacheControl(p, c.req.query('v'), assets.manifest, ASSET_HASHING);
|
||||
const hash = assets.deliveryFiles[p].h;
|
||||
const cacheControl = assetCacheControl(p, c.req.query('v'), assets.manifest, ASSET_HASHING, assets.deliveryFiles);
|
||||
if (COMPRESSIBLE.test(p)) return sendCompressed(c, compressedEntry(p, raw, MIME[ext] || file.type), cacheControl, hash);
|
||||
return new Response(raw, { headers: { 'Content-Type': file.type, 'Cache-Control': cacheControl, 'X-Asset-Hash': hash } });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user