Problem
app/api/auth/logout/route.ts makes a logout request to the upstream auth server (http://localhost:3001/auth/logout) and never inspects the response. The route unconditionally returns { success: true } and clears the local refresh_token cookie regardless of whether the upstream auth server confirmed the logout.
As a result, a client of this endpoint will always believe the logout succeeded — even if the auth server returned 5xx or rejected the request.
Reproduction (conceptual)
- Take the auth server offline (or make it return 500 for
POST /auth/logout).
- Call
POST /api/auth/logout from a logged-in client with a valid refresh_token.
- Expected: 502 Bad Gateway (or similar failure signal).
- Actual: 200 OK with
{ success: true } and a cleared cookie. The client believes the logout succeeded; the session on the auth server may still be valid.
Suggested fix
Bind the upstream response and check ok before constructing the local response:
const upstreamRes = await fetch("http://localhost:3001/auth/logout", { ... })
if (!upstreamRes.ok) {
return NextResponse.json({ success: false }, { status: 502 })
}
This propagates a 502 Bad Gateway when the upstream logout fails, preserving the local cookie-clearing behaviour only on success.
Discovered during
Code review on feat/ci-virtualization-network-policies (PR #470, commits ddf4512, b8883ad, 614517e). The lint cleanup removed the unused apiRes binding, which made the missing response inspection more obvious.
The bug is pre-existing — it predates PR #470 and was deliberately deferred from those lint-cleanup commits because it is a contract bug, not a lint issue.
Acceptance criteria
Problem
app/api/auth/logout/route.tsmakes a logout request to the upstream auth server (http://localhost:3001/auth/logout) and never inspects the response. The route unconditionally returns{ success: true }and clears the localrefresh_tokencookie regardless of whether the upstream auth server confirmed the logout.As a result, a client of this endpoint will always believe the logout succeeded — even if the auth server returned 5xx or rejected the request.
Reproduction (conceptual)
POST /auth/logout).POST /api/auth/logoutfrom a logged-in client with a validrefresh_token.{ success: true }and a cleared cookie. The client believes the logout succeeded; the session on the auth server may still be valid.Suggested fix
Bind the upstream response and check
okbefore constructing the local response:This propagates a 502 Bad Gateway when the upstream logout fails, preserving the local cookie-clearing behaviour only on success.
Discovered during
Code review on
feat/ci-virtualization-network-policies(PR #470, commitsddf4512,b8883ad,614517e). The lint cleanup removed the unusedapiResbinding, which made the missing response inspection more obvious.The bug is pre-existing — it predates PR #470 and was deliberately deferred from those lint-cleanup commits because it is a contract bug, not a lint issue.
Acceptance criteria
app/api/auth/logout/route.tsreturns a non-2xx response when the upstream auth server returns a non-2xx response.await).