Next.js application for encrypted chat, contacts, account recovery, push notifications, and MongoDB persistence.
- Copy env template:
cp .env.example .env.local- Set real values for:
MONGODB_URINEXT_PUBLIC_RELAY_WS_URLNEXT_PUBLIC_VAPID_PUBLIC_KEYVAPID_PUBLIC_KEYVAPID_PRIVATE_KEYVAPID_SUBJECT
- Build and run:
pnpm install --frozen-lockfile
pnpm build
pnpm start- Liveness:
GET /api/healthz - Deep check (includes Mongo ping):
GET /api/healthz?deep=1
- Security headers and CSP enabled via
next.config.ts. - API middleware applies:
- in-memory rate limiting
X-Request-IDCache-Control: no-storefor/api/*
- Input size and format limits are enforced on high-risk API routes.
- Mongo indexes are initialized automatically at startup.
- Temporary accounts expire automatically after 24h.
- Expired temporary users are cleaned with related contacts, messages, room members, and push subscriptions.
- For multi-instance production, replace in-memory API rate limiting with a shared store (Redis).
- Run behind HTTPS reverse proxy (Nginx/Traefik/Cloudflare).
- Force TLS; do not expose plain
ws://publicly. - Set
NODE_ENV=production. - Use managed MongoDB with backups and alerts.