App Router'daki kimlik doğrulama birkaç katmanı kapsar — oturumlar, middleware, sunucu tarafı kontroller ve Server Actions koruması. Modern yaklaşım, sunucu tarafı oturum doğrulamasına yalnızca istemci tarafı kontrollerin ön plana koyar.
Oturum stratejisi
Cookie-based sessions (httpOnly cookie):
✓ Store a signed session id or encrypted JWT in an httpOnly, secure cookie
✓ httpOnly = not readable by JavaScript → protects against XSS token theft
✓ Use a library: Auth.js (NextAuth), Clerk, Lucia, or a custom solution
1. Middleware'de kaba geçit denetimi (hızlı, ama tam hikaye değil)
() {
session = req..()?.;
(req...() && !session) {
.( (, req.));
}
.();
}
