Add a header just for a particular branch deploy

Hi @Jiveworld,

Redirects and Headers specified in netlify.toml are site-wide and cannot be configured specifically for some contexts. So, what you’re seeing is expected behaviour.

What you can do instead is, use _headers file. You can create a _headers file with the required content, and then in the build command for your branch, you can specify the command as npm run build && cp _headers /public/_headers. Do note, you need to replace npm run build with your build command and /public/ with your publish folder.

Hope this helps.

1 Like