From df1530b2d20f7cfda47271c8b1828499032012f4 Mon Sep 17 00:00:00 2001 From: Gabriel Costa Date: Fri, 14 Aug 2026 23:33:57 +0100 Subject: [PATCH] bug: Fix logout backend response and docker build Signed-off-by: Gabriel Costa --- Dockerfile | 2 +- src/auth/AuthContext.test.tsx | 2 +- src/auth/AuthContext.tsx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 025e22f..7661614 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN npm ci --no-audit --no-fund # outDir is "server/public", so output lands at /ui/server/public here. FROM ui-deps AS ui-build WORKDIR /ui -COPY openapi.json orval.config.ts index.html vite.config.ts ./ +COPY openapi.json orval.config.ts index.html vite.config.ts build-constants.ts ./ COPY tsconfig.json tsconfig.app.json tsconfig.node.json ./ COPY public ./public COPY src ./src diff --git a/src/auth/AuthContext.test.tsx b/src/auth/AuthContext.test.tsx index 6767405..9a1a8ec 100644 --- a/src/auth/AuthContext.test.tsx +++ b/src/auth/AuthContext.test.tsx @@ -256,7 +256,7 @@ describe("AuthContext", () => { expect(window.location.href).toBe("/app/login"); }); - expect(api.post).toHaveBeenCalledWith("/auth/logout"); + expect(api.post).toHaveBeenCalledWith("/auth/logout", {}); expect(setCsrfToken).toHaveBeenLastCalledWith(null); }); diff --git a/src/auth/AuthContext.tsx b/src/auth/AuthContext.tsx index eb413ca..c5cf5ec 100644 --- a/src/auth/AuthContext.tsx +++ b/src/auth/AuthContext.tsx @@ -136,7 +136,9 @@ export function AuthProvider({ children }: { children: ReactNode }) { const logout = useCallback(async (): Promise => { try { - await api.post<{ ok: boolean }>("/auth/logout"); + // Empty body would still send Content-Type: application/json, which Fastify's + // default JSON parser 400s on — send {} to keep the header/body honest. + await api.post<{ ok: boolean }>("/auth/logout", {}); } catch { // Client-side logout should still complete if the server-side session is already gone // or the CSRF token has expired.