chore: compress and lazy load client code (#2425)

This commit is contained in:
Philip Okugbe
2026-08-25 03:29:56 +01:00
committed by GitHub
parent a415b86193
commit a0ec93506c
7 changed files with 186 additions and 70 deletions
@@ -71,6 +71,16 @@ export class StaticModule implements OnModuleInit {
await app.register(fastifyStatic, {
root: clientDistPath,
wildcard: false,
preCompressed: true,
setHeaders: (reply: any, pathName: string) => {
// Vite content-hashes everything under /assets, so they can be cached forever
if (/[\\/]assets[\\/]/.test(pathName)) {
reply.header(
'Cache-Control',
'public, max-age=31536000, immutable',
);
}
},
});
app.get(RENDER_PATH, (req: any, res: any) => {