This contains reproduction for a weird behavior between H3 proxyRequest and Bun.
(Caddy | Nginx) > Bun (runtime) > H3 (server code)
- http://localhost:3001 (bun)
- http://localhost:3002 (node)
minimal Caddyfile and NGINX config are also included to make it easier to reproduce.
Then just add these in your /etc/hosts file:
127.0.0.1 bun.test
127.0.0.1 node.testWhen requests pass through Caddy or NGINX to Bun/H3 using proxyRequest, H3 successfully fetches the upstream response, but the reverse proxy still returns 502.
Direct access to the underlying applications returns the correct response.
| Request | Expected | Actual |
|---|---|---|
| http://bun.test | 200 | 200 |
| http://node.test | 200 | 200 (For some reason) |
| http://bun.test/200 | 200 | 200 |
| http://node.test/200 | 200 | 502 via Caddy; hangs indefinitely via NGINX |
| http://localhost:3001/200 | 200 | 200 |
| http://localhost:3002/200 | 200 | 200 |
This only happens in proxyRequest. If you actually set the response yourself like setResponseStatus(event, 401), it still works.
Regards to actual command ran in the docker-compose.yml, you can remove --bun flag on the node but it still won't work.
This especially confusing on Nuxt app when Bun runtime is used but bun preset is not set in nuxt.config.
export default defineNuxtConfig({
// .....
nitro: {
preset: "bun",
},
});