From 761229e4d2184988cdbc67d99665db4166974ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Tue, 9 Jul 2024 17:09:31 +0200 Subject: [PATCH] fix(core): Use Custom cache-control headers force cache-revalidation on `/types/*.json` (no-changelog) (#9981) --- packages/cli/src/Server.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index b6fce88b9c..a7c854d7fb 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -364,10 +364,18 @@ export class Server extends AbstractServer { next(); } }; + const setCustomCacheHeader = (res: express.Response) => { + if (/^\/types\/(nodes|credentials).json$/.test(res.req.url)) { + res.setHeader('Cache-Control', 'no-cache, must-revalidate'); + } + }; this.app.use( '/', - express.static(staticCacheDir, cacheOptions), + express.static(staticCacheDir, { + ...cacheOptions, + setHeaders: setCustomCacheHeader, + }), express.static(EDITOR_UI_DIST_DIR, cacheOptions), historyApiHandler, );