h3 icon indicating copy to clipboard operation
h3 copied to clipboard

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

Open TimGuendel opened this issue 1 year ago • 0 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

TimGuendel avatar Mar 11 '24 10:03 TimGuendel