cd frontend
npm installnpm testnpm run dev- Open http://localhost:3000
- Press F12 (DevTools)
- Check Console - should be clean (no CSP violations)
- Check Network tab → Headers → Response Headers
- Verify security headers are present
✅ Done! Security headers are now active.
| Document | Purpose | When to Use |
|---|---|---|
| INSTALLATION_CHECKLIST.md | Step-by-step installation | First time setup |
| SECURITY_HEADERS_SUMMARY.md | Executive overview | Understanding what was done |
| docs/security/headers.md | Complete guide | Adding resources, troubleshooting |
| docs/security/TESTING_GUIDE.md | Testing procedures | Running tests, validation |
| docs/security/README.md | Quick reference | Common tasks |
// Edit: frontend/middleware.ts
'connect-src': [
"'self'",
'https://new-api.example.com', // ← Add here
],- Check browser console for error
- Note the blocked URL
- Add to appropriate directive in
frontend/middleware.ts - Restart dev server
- Test again
npm run test:security./scripts/validate-security-headers.sh https://your-app.com✅ Content Security Policy - Prevents XSS attacks ✅ HSTS - Enforces HTTPS ✅ X-Frame-Options - Prevents clickjacking ✅ X-Content-Type-Options - Prevents MIME sniffing ✅ Referrer-Policy - Protects sensitive URLs ✅ Permissions-Policy - Reduces attack surface ✅ Cross-Origin Policies - Isolates browsing context
npm test # All tests
npm run test:security # Security tests only
npm run test:coverage # With coverage report- Start server:
npm run dev - Open browser DevTools (F12)
- Check Console for CSP violations
- Check Network → Headers for security headers
- Mozilla Observatory - Target: Grade A
- SecurityHeaders.com - Target: Grade A
- CSP Evaluator - Target: No HIGH issues
Error: Refused to load...
Fix: Add the blocked resource to CSP in frontend/middleware.ts
See: docs/security/headers.md#troubleshooting
Error: Cannot find module 'jest'
Fix:
npm installError: Cannot find module 'next/server'
Fix: These will resolve after npm install
- Tests pass:
npm test - No console errors
- No CSP violations
- All pages work
- Staging tested
- Validation script passes
- Online scanners run
- Security team approval
- Check documentation - See links above
- Search for error - Google the CSP violation message
- Contact security team - For complex issues
frontend/middleware.ts- Main implementationfrontend/__tests__/security-headers.test.ts- Testsdocs/security/headers.md- Documentation- And 9 more...
frontend/next.config.js- Static headersfrontend/app/layout.tsx- Nonce supportfrontend/package.json- Dependencies- And 2 more...
See SECURITY_HEADERS_SUMMARY.md for complete list.
# Setup
cd frontend && npm install
# Test
npm test
npm run test:security
npm run test:coverage
# Develop
npm run dev
npm run type-check
npm run lint
# Deploy
npm run build
npm start
# Validate
./scripts/validate-security-headers.sh https://your-app.comStatus: ✅ Ready to Use
Next Step: Run cd frontend && npm install
Time Required: 5 minutes
Questions? See docs/security/README.md