Repository navigation
Commit 21604ac
committed
fix(server): set Content-Type on basic-auth 401 responses
hono's basicAuth middleware returns its 401 response without setting a
Content-Type header. Bun's HTTP serializer fills the missing slot with
`application/octet-stream`, which Chromium briefly treats as a
download-attachment trigger before settling on the basic-auth dialog.
The race produces 2-3 dialog flashes before the password field accepts
input, and Playwright surfaces it as `Error: Download is starting` on
the navigation call. Subresources (favicons, JS bundle, CSS, manifest)
each hit basic-auth independently and each get the same octet-stream
401, compounding the loop.
Wrap the basicAuth call in AuthMiddleware so a 401 response with no
Content-Type gets `text/plain; charset=utf-8` added before being
re-thrown. Authenticated requests are unaffected.
Verified by:
- `curl -i http://localhost:40960/` now returns
`content-type: text/plain; charset=utf-8` on the 401.
- `bun typecheck` and `bun test` clean from packages/opencode.
Refs upstream issue anomalyco#183251 parent cf903b1 commit 21604ac
1 file changed
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
50 | 68 | | |
51 | 69 | | |
52 | 70 | | |
| |||
0 commit comments