node-server icon indicating copy to clipboard operation
node-server copied to clipboard

Bug: `serveStatic({ precompressed: true })` returns `text/plain`

Open SaekiTominaga opened this issue 11 months ago • 0 comments

Environment

Steps to reproduce

  1. Set precompressed: true for serveStatic()
  2. Call c.res as in the following code
  3. Prepare the compressed file (e.g. with-compressed.html and with-compressed.html.br)
  4. Content-Type is set to text/plain;charset=UTF-8 😥
app.use(
  serveStatic({
    root: "static",
    precompressed: true,
    onFound: (_path, c) => {
      const { res } = c;
    },
  })
);

Minimal Reproducible Example

I have created MRE in the following repository. https://github.com/SaekiTominaga/mre-hono-static-compress-node

  • npm run dev1http://localhost:3000/with-compressed.html returns text/html 👍
  • npm run dev2http://localhost:3000/with-compressed.html returns text/plain 👎
  • npm test → "called `c.res` – with compressed" test fails

SaekiTominaga avatar Feb 09 '25 05:02 SaekiTominaga