From 70dfefa82368c8f21b3b6fcf8ac9a1a2cb143c47 Mon Sep 17 00:00:00 2001 From: xEsiah Date: Tue, 20 Oct 2026 14:08:43 +0200 Subject: [PATCH] fix(api): disable caching for cloud API responses Browsers applied heuristic caching to JSON API responses because no Cache-Control header was set, serving stale file lists after delete or upload even with a hard refresh. Force no-store on all /api/cloud/* responses. --- backend/src/routes/auth.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/routes/auth.ts b/backend/src/routes/auth.ts index 1b40e3e..c68d637 100644 --- a/backend/src/routes/auth.ts +++ b/backend/src/routes/auth.ts @@ -79,6 +79,14 @@ const SELECT_USER = ` LEFT JOIN user_avatars ua ON ua.user_id = u.id`; export const registerAuthRoutes = (app: App, db: Db, config: Config): void => { + // Aucune reponse de l'API ne doit etre mise en cache. Sans en-tete explicite, + // les navigateurs appliquent un cache heuristique et reservent une liste de + // fichiers obsolete apres une suppression ou un depot. + app.use("/api/cloud/*", async (context, next) => { + await next(); + context.header("cache-control", "no-store"); + }); + app.use("/api/cloud/*", attachUser(db)); const limiter = createRateLimiter(config.RATE_LIMIT_LOGIN_MAX, config.RATE_LIMIT_LOGIN_WINDOW_MS);