Skip to main content
Mizu automatically applies security headers to protect your frontend from common web vulnerabilities.

Default Security Headers

The frontend middleware adds these headers:

X-Content-Type-Options

Purpose: Prevents MIME-sniffing attacks
Browsers won’t try to guess content types, preventing attacks where malicious files are disguised as images.

X-Frame-Options

Purpose: Prevents clickjacking
Your site can only be embedded in iframes from the same origin, blocking clickjacking attacks.

X-XSS-Protection

Purpose: Legacy XSS protection
Enables browser’s built-in XSS filter (legacy browsers).

Referrer-Policy

Purpose: Controls referrer information
Sends full URL to same-origin requests, only origin to cross-origin.

Disabling 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 without unsafe-inline:

HTTPS Enforcement

Use the secure middleware:

CORS Configuration

For API endpoints:

Source Map Protection

Block source maps in production:
Source maps expose your source code. Only enable in staging/development.

Best Practices

1. Use HTTPS

Always use HTTPS in production:

2. Set CSP

Implement Content Security Policy:

3. Sanitize User Input

In Go handlers:
In frontend:

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

Next Steps

Helmet Middleware

Comprehensive security headers

CORS Middleware

Cross-origin resource sharing

Rate Limiting

Protect against abuse