Skip to content

Bug: serveStatic({ precompressed: true }) returns text/plainΒ #226

@SaekiTominaga

Description

@SaekiTominaga

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 dev1 β†’ http://localhost:3000/with-compressed.html returns text/html πŸ‘
  • npm run dev2 β†’ http://localhost:3000/with-compressed.html returns text/plain πŸ‘Ž
  • npm test β†’ "called `c.res` – with compressed" test fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions