From cbe33bf563e9dd75a5b4a9529cdda9baf67d91ad Mon Sep 17 00:00:00 2001 From: Gitea Actions <-2+gitea-actions@noreply.localhost> Date: Tue, 20 Oct 2026 12:09:07 +0000 Subject: [PATCH] fix(api): disable caching for cloud API responses (#14) 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. --------- Co-authored-by: xEsiah Reviewed-on: https://git.cohaise.dev/Esiah/CoHaiSe-CLOUD/pulls/14 Reviewed-by: Esiah Co-authored-by: Gitea Actions <-2+gitea-actions@noreply.localhost> --- 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);