_headers file and Astro

Hi all, new to CF Pages and Astro (static generated). Even so, I've managed to create a nice blog site pretty quickly. However, I want to make use of some custom headers but I can't figure out how to make the Astro build process create a file called _headers in the dist root folder. If I create a /src/pages/_headers.js, the Astro build ignores it. If I rename to headers.js it produces the correct output but with the wrong name, Can anyone guide me to the correct process please? Thanks.
3 Replies
i40west
i40west2d ago
Files under /src/ are processed by Astro. For _headers you want it to be used as-is as a static asset, so it should be in your directory for static assets, which is /public/ by default.
i40west
i40west2d ago
Docs
Project Structure
Learn how to structure a project with Astro.
totallyinformation
totallyinformationOP19h ago
Hi, thanks for your response. However, the _headers file isn't a static asset, it is a private file used by Cloudflare Pages and most certainly should not be publicly available. I just can't work out how to get this to work with Astro.
Want results from more Discord servers?
Add your server