Private authenticated area for private.agentlab.in.
Milestone 1 is intentionally small:
/signup/login/logout/dashboard- email/password auth
- DB-backed sessions
- HTTP-only session cookie
- protected dashboard showing
You're logged in as "Username"
- Next.js App Router
- TypeScript
- Drizzle ORM
- PostgreSQL
- Argon2id password hashing via
@node-rs/argon2
Create .env.local:
DATABASE_URL="postgres://USER:PASSWORD@HOST:5432/DATABASE?sslmode=require"Run migrations:
npm run db:migrateStart the app:
npm run devOpen http://localhost:3000.
Passwords are hashed with argon2id and plaintext passwords are never stored.
Sessions use a random 32-byte token. The browser receives only the raw token in an HTTP-only cookie; the database stores a SHA-256 hash of the token with an expiry timestamp.
Login creates a fresh session and deletes any older sessions for that user. Logout deletes the current session and clears the cookie.
The cookie is httpOnly, sameSite=lax, scoped to /, and secure in production. Server Actions are used for the auth form POSTs, which gives Next.js same-origin Server Action protections for the normal form submission path. If this app later adds API route mutations, add explicit CSRF tokens or another CSRF strategy for those routes.
Login and signup have a basic DB-backed rate limit keyed by action, normalized email, and request IP.
Vercel needs DATABASE_URL set in the Production, Preview, and Development environments before the app can complete auth flows.
The CNAME file declares:
private.agentlab.inDNS should point the subdomain at Vercel:
private CNAME cname.vercel-dns.comFirst, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.