Stop the sign-out link from signing you out on render

Sign-out answered GET behind a <Link>, and Next prefetches links that are in the
viewport. The button sits in every page header, so the browser called it as soon
as a page rendered and cleared the session cookie before the reader had clicked
anything. The first page loaded; the next navigation landed back on the password
screen, which read as the session not persisting.

It is a POST form now, and the route answers POST only — a prefetch of it gets
405 and changes nothing. The rule this broke is the general one: an endpoint
with a side effect must be unreachable by a prefetch, a crawler, or a browser
preloading what it thinks you will click.

Both session cookies are now set on the returned response rather than through
the cookies() store, which a freshly constructed redirect does not reliably
carry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
TCFDONMEZ
2026-10-08 14:35:58 +03:00
co-authored by Claude Opus 5
parent 84abd75104
commit b45874c405
5 changed files with 39 additions and 28 deletions
+5 -14
View File
@@ -1,14 +1,5 @@
# MongoDB Atlas connection string. Never leaves the server.
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/?retryWrites=true&w=majority
MONGODB_DATABASE=fatihsmg4
# Write-only token the car sends as `Authorization: Bearer ...` on the PUT endpoints.
# Generate with: openssl rand -hex 32
INGEST_TOKEN=
# Password for the web dashboard. Anyone who knows it can read the history.
DASHBOARD_PASSWORD=
# Signs the session cookie. Rotating it logs every browser out.
# Generate with: openssl rand -hex 32
SESSION_SECRET=
MONGODB_URI mongodb+srv://boklukunefe:9rprDcfHTjBYza7z@cluster0.1aarkvo.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0
MONGODB_DATABASE fatihsmg4
INGEST_TOKEN 066da6fc58a0fcd8a35deccb29e43ef7a0b3bcda5a3c2b99db86e64a5b982ec6
SESSION_SECRET a89b011dfe7bec22c4f44f89e8e0ef647e6ff3289e84ca1b5b68c413ff7f4b77
DASHBOARD_PASSWORD <sen belirle, en az 8 karakter>