Production & Deployment
Production Hardening & Verification
How applications generated with create-modern-mern-app maintain security, performance, and reliability in production.
1. Security Architecture
Helmet Security Headers
Standardized HTTP headers preventing MIME sniffing, XSS, and clickjacking attacks.
Scoped CORS Policy
Restricts cross-origin API access strictly to your client URL with credentials: true.
CSRF Protection
Enforces X-Requested-With: mern-client headers on all state-modifying requests.
Brute-Force Rate Limiting
Shared IP rate limiting on login and registration with opt-in MongoDB store for multi-replica setups.
2. Building for Production
From the workspace root, run the unified build script to bundle both client and server:
bash
bash
npm run buildThis compiles TypeScript server files into NodeNext ES Modules and builds the Vite frontend into optimized static assets.
3. Running Production Tests
Test your application using the integrated test harness:
bash
bash
npm test