Configuration
Configuration headers
Define an async headers function returning source patterns and key/value pairs. Test the final response after framework and proxy processing. Truly immutable hashed assets receive a framework-controlled cache policy; do not assume configuration can override it. These public security headers are not a complete security policy. Source: https://nextjs.org/docs/app/api-reference/config/next-config-js/headers. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
async headers()Working Example
Example Snippetnextjs
import type { NextConfig } from 'next';const config: NextConfig = { async headers() { return [{ source:'/catalog/:path*', headers:[ {key:'X-Content-Type-Options', value:'nosniff'}, {key:'Referrer-Policy', value:'strict-origin-when-cross-origin'} ] }]; }};export default config;