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” }
}

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


The problem is that even with this file, the headers remain the same.
image.png
Was this page helpful?