_headers file in astro project
Greetings,
I'm using astro framework with cloudflare adapter: https://docs.astro.build/en/guides/integrations-guide/cloudflare
I tried to implement _headers file. And it works with static site mode, but not with
output: server
.
In both cases cf detects _headers file (pic related) but it does not apply it here https://e930aa71.code-webapp.pages.dev/ and applies it here https://ff87c8cd.code-webapp.pages.dev/
The only one difference between two links is output: server
in first one, and output: hybrid
in second one (it treats it like static site).
I found similar thread https://community.cloudflare.com/t/values-in-headers-files-arent-applying-for-custom-domain/625640/5 but no help there.
If you can't help me maybe you know where I should send an issue.Docs
@astrojs/cloudflare
Learn how to use the @astrojs/cloudflare SSR adapter to deploy your Astro project.
Welcome to Astro.
Astro description
Welcome to Astro.
Astro description
6 Replies
up
_headers is only executed if it hits the Pages asset serving backend
output: server
makes Astro fully SSR which means there's a Worker (Function) in front handling the serving of content, it doesn't go to the Pages asset serving
I'd assume they still go there for static assets like js/css/images but not 100% on the behaviour therethank you @Walshy | Deploying
@Walshy | Deploying so
_headers
won't work if output is set to server? I'm trying to add this and it doesn't seem to work. I'm also using astro with output:server
Correct, Functions don't run the asset serving piece of Pages (which is what handles _redirects)
you need to add it within Astro's SSR
thanks. @Walshy | Deploying