Node js http-proxy request not working properly

I am using node-http-proxy.

I am trying to proxy a request at path xxxx In my target server I am getting request.
But in network tab request is hitting current host, and giving 404 Not found as route is not available in current host.


const targetMap = {
    '/xxxxxx': {
        prefix: `xxxxxxxx`
    },
};

const target = Object.keys(targetMap)
        .map((re) => {
            const match = ctx.path.match(re);
            if (match) {
                return `${targetMap[re].prefix}`;
            }
        })
        .filter((item) => item)[0];

// Proxy the request
        proxy.web(ctx.req, ctx.res, { target, changeOrigin: true }, (err) => {
            if (err) {
                LOGGER.error({ err }, 'Failed to proxy request!');
                ctx.status = 500;
                ctx.body = 'Something went wrong.';
            }
        });