Skip to content

socket hang up #113

@ahoiroman

Description

@ahoiroman

Hello,

I got a pretty weird problem:

I created this proxy:

axios: {
        credentials: true,
        proxy: true,
        baseURL: process.env.NUXT_PUBLIC_BASE_URL,
        debug: process.env.NODE_ENV && process.env.NODE_ENV === 'development',
    },
    proxy: {
        '/backend': {
            target: process.env.NUXT_PUBLIC_APP_URL, // http://api.test
            changeOrigin: true,
            secure: process.env.NODE_ENV && process.env.NODE_ENV === 'development',
            credentials: true,
            rewrite: (path) => path.replace(/^\/backend/, ''),
            common: {
                'Accept': 'application/json, text/plain, */*'
            },
        },
    },
    ```

Now If I do something like:

return useFetch(/backend${url}, {
server: true,
credentials: "include", // Allow browser to handle cookies
headers,
...opts,
pick: pick
});


I get this error:

http proxy error: Error: socket hang up
at connResetException (node:internal/errors:693:14)
at Socket.socketOnEnd (node:_http_client:478:23)
at Socket.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1344:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
timestamp: true,
error: Error: socket hang up
at connResetException (node:internal/errors:693:14)
at Socket.socketOnEnd (node:_http_client:478:23)
at Socket.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1344:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ECONNRESET'
}
}



If I use

return useFetch(http://api.test/${url}, {
server: true,
credentials: "include", // Allow browser to handle cookies
headers,
...opts,
pick: pick
});


everything works like a charm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions