unjs / h3

⚡️ Minimal H(TTP) framework built for high performance and portability

Home Page:https://h3.unjs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nuxt SSR DEV mode: proxyRequest does not work with node 19+ (works with 18)

TimGuendel opened this issue · comments

Environment

Windows 11
Node Version Manager
Node 19.0.0
Nuxt 3.10.3
Nitro 2.8.1

Reproduction

I was not able to reproduce it, but maybe someone has an idea. I don't know how to debug this.

Describe the bug

This catch-all server middleware in my Nuxt App works with Node 18:

import { joinURL } from 'ufo';
export default defineEventHandler((event) => {
    const config = useRuntimeConfig();
    const path = event.path.replace(/^\/api\//, '');
    const target = joinURL(config.backendUrl, path);
    console.log('Proxy -->', target);
    return proxyRequest(event, target);
});

But when I use Node 19.0.0 or higher, the console.log is executed but then the webapp does not load anymore.
Replacing proxyRequest(event, target); with return event solves the problem.

This happens in DEV mode only. A production build works.

Additional context

No response

Logs

No response

If you are still experiencing issues, please share a runnable reproduction 🙏🏼

The problem came from the "connection" httpheader that was set to "close" instead of "keep-alive" ✅