Why do Nginx add_header directives need the 'always' flag?
Without `always`, Nginx omits custom security and CORS headers on 4xx and 5xx error responses, causing confusing CORS failures whenever an API returns 401 or 500.
Generate production-hardened reverse proxy and edge configs in one click—combining HSTS, CSP, CORS preflight, upload limits (413 fix), read timeouts (504 fix), and SPA fallbacks (404 fix).
security-headers.conf
Without `always`, Nginx omits custom security and CORS headers on 4xx and 5xx error responses, causing confusing CORS failures whenever an API returns 401 or 500.
Use `_headers` for static sites on Cloudflare Pages (zero compute cost). Use a Cloudflare Worker when proxying dynamic origins or handling dynamic CORS origins.
It lets you configure `client_max_body_size` and `proxy_read_timeout` alongside your security headers in a single clean snippet.