nuxt-alt / proxy

An alternative module to @nuxtjs/proxy
MIT License
24 stars 5 forks source link

2.4.3: ERR_UNSUPPORTED_ESM_URL_SCHEME on startup #17

Closed TimGuendel closed 11 months ago

TimGuendel commented 11 months ago

After upgrading to 2.4.3, I am getting this error when starting my Nuxt App:

βœ” Nitro built in 3651 ms nitro 09:01:43 [nitro] [unhandledRejection] Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' at __node_internal_captureLargerStackTrace (node:internal/errors:496:5) at new NodeError (node:internal/errors:405:5) at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:136:11) at defaultLoad (node:internal/modules/esm/load:87:3) at nextLoad (node:internal/modules/esm/loader:163:28) at ESMLoader.load (node:internal/modules/esm/loader:603:26) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22) at new ModuleJob (node:internal/modules/esm/module_job:64:26) at #createModuleJob (node:internal/modules/esm/loader:480:17) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) { code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME' }

My nuxt config:

    proxy: {
        proxies: {
            '/api': {
                target: process.env.BACKEND_URL,
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
                xfwd: true,
                configure: (proxy) => {
                    proxy.on('proxyReq', (proxyReq) => {
                        console.log('proxyReq', proxyReq);
                    });
                },
            },
        },
    },
Denoder commented 11 months ago

Unfortunately, I don't test modules in a Windows environment, so I am unable to provide assistance or a fix as to fixing the path issue on this line: https://github.com/nuxt-alt/proxy/blob/3c86111314ad869cbd2e3578fcc768be656e041f/src/runtime/proxy-plugin.nitro.ts#L156

You can make a pull request if you do know a solution.

TimGuendel commented 11 months ago

Thanks for the new version - now with 2.4.4 I am now getting this error πŸ€”

βœ” Nitro built in 4670 ms nitro 13:33:01 [nitro] [unhandledRejection] TypeError: Cannot read properties of undefined (reading 'configure') at getFunction (C:\dev\frontend-web-2\node_modules\@nuxt-alt\proxy\dist\runtime\proxy-plugin.nitro.mjs:101:55) at async Promise.all (index 1) at (C:\dev\frontend-web-2\node_modules\@nuxt-alt\proxy\dist\runtime\proxy-plugin.nitro.mjs:12:3)

Denoder commented 11 months ago

@TimGuendel should be fixed now

TimGuendel commented 11 months ago

@TimGuendel should be fixed now Wow, thanks! It's working now πŸ‘