How do I set custom headers with Elysia

I am using Elysia with CloudflareAdapter to render pages. In the build I generate: /out/_worker.js (server and tsx) /out/static (images, css, js) This is my wrangler.json:
{
“$schema”: “node_modules/wrangler/config-schema.json”,
“name”: “freeflash”,
“main”: “out/_worker.js”,
“compatibility_date”: “2025-06-01”,
“assets”: { ‘directory’: “out/static” }
}
{
“$schema”: “node_modules/wrangler/config-schema.json”,
“name”: “freeflash”,
“main”: “out/_worker.js”,
“compatibility_date”: “2025-06-01”,
“assets”: { ‘directory’: “out/static” }
}
From what I understand from the docs (https://elysiajs.com/integrations/cloudflare-worker), requests for static assets dont go through the worker, so I should use a _headers file in file instead of a middleware:
#/out/_header
/static/*
Cache-Control: public, max-age=31536000, immutable
#/out/_header
/static/*
Cache-Control: public, max-age=31536000, immutable
The problem is that even with this file, the headers remain the same.
No description
2 Replies
SuperHelpflare
Feedback
Feedback has been submitted! Thank you :)
davi
daviOP7d ago
Solved, i needed to put it in out/static/ and change the file to: /assets/* Cache-Control: public, max-age=31536000, immutable

Did you find this page helpful?