Introducing Custom Headers for Cloudflare Pages
Oct 27, 2021Nevi Shah, Greg Brimble

Summary
Introduced native support for custom headers and enhanced redirects in Cloudflare Pages projects. This is achieved by creating a `_headers` file in the build directory, which defines rules for applying headers based on URL patterns. The underlying matching engine is modeled after the URLPattern specification. This enables configuration of SEO headers (e.g., X-Robots-Tag), security headers (e.g., X-Frame-Options, Content-Security-Policy), and CORS headers (e.g., Access-Control-Allow-Origin). Enhanced redirects also support splats, placeholders, and status codes using the same engine.