Default Security Headers
The frontend middleware adds these headers:X-Content-Type-Options
Purpose: Prevents MIME-sniffing attacksX-Frame-Options
Purpose: Prevents clickjackingX-XSS-Protection
Purpose: Legacy XSS protectionReferrer-Policy
Purpose: Controls referrer informationDisabling Security Headers
If using the helmet middleware:Content Security Policy (CSP)
Use the helmet middleware for CSP:CSP with Vite
Vite uses inline scripts in development. Production build should work withoutunsafe-inline:
HTTPS Enforcement
Use the secure middleware:CORS Configuration
For API endpoints:Source Map Protection
Block source maps in production:Best Practices
1. Use HTTPS
Always use HTTPS in production:2. Set CSP
Implement Content Security Policy:3. Sanitize User Input
In Go handlers:4. Validate on Server
Never trust client-side validation:5. Use HTTP-Only Cookies
For authentication tokens:6. Rate Limit API Endpoints
Security Checklist
- HTTPS enabled in production
- Security headers configured
- CSP implemented
- CORS properly configured
- Source maps disabled in production
- User input sanitized
- Server-side validation
- HTTP-only cookies for auth
- Rate limiting on APIs
- Dependencies regularly updated