Autentifikimi në App Router përfshin disa shtresa — seanca, middleware, verifikime anësor serverit dhe mbrojtja e Server Actions. Qasja moderne favorizon verifikimin e seancës anësor serverit mbi kontrollet vetëm të klientit.
Strategjia e seancës
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. Mbyllja e gjerë në middleware (e shpejtë, por jo e gjithë historia)
() {
session = req..()?.;
(req...() && !session) {
.( (, req.));
}
.();
}
