Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nelrondon/backend-proyecto-estructuras/llms.txt

Use this file to discover all available pages before exploring further.

POST /api/logout terminates the current session by overwriting the token cookie with an empty string and setting its expiry to the Unix epoch (new Date(0)). The browser immediately discards the cookie on receipt, so any future request to a protected route will be rejected by the authRequired middleware with a 401. Because there is no server-side session store, this is the only mechanism available to invalidate a token before its 7-day natural expiry.

Endpoint

POST /api/logout
Authentication: None required. The endpoint does not validate the existing cookie — it clears it unconditionally, whether or not a valid session was present.

Request Body

No request body is needed. The server ignores any payload sent with this request. The server calls:
res.cookie("token", "", { expires: new Date(0) });
This instructs the browser to set token to an empty string with an expiry date in the past, which causes the browser to immediately delete the cookie. Subsequent requests will have no token cookie to present to authRequired.

Example Request

# -b sends the stored cookie; the server then expires it
curl -b cookies.txt -s -X POST https://your-api.com/api/logout

Response

200 — Success

message
string
A confirmation string indicating the session has been cleared. Always "Usuario deslogueado".
{
  "message": "Usuario deslogueado"
}
This endpoint always returns 200, even if no valid token cookie was present in the request. It is safe to call logout multiple times or from an already-unauthenticated state.
Logout only clears the cookie on the responding client. If the same JWT was copied and is being used by another client (e.g. a different browser or a tool like curl), that token remains cryptographically valid until it expires in 7 days. There is no server-side blocklist in the current implementation.

Build docs developers (and LLMs) love