Rob--W / cors-anywhere

CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxied request.
MIT License
8.5k stars 5.92k forks source link

API domain name resolution problem #461

Open MATACE opened 1 year ago

MATACE commented 1 year ago

In the file cors-anywhere.js the code var location = parseURL(req.url.slice(1)) have some problem. When I send an axios request

        const proxyUrl = 'http://127.0.0.1:38000/';         // my cors-anywhere server
        const targetUrl = 'http://localhost:38080/api/v5/configs/broker';

        axios
            .get(proxyUrl + targetUrl, {
                auth: {
                    username: username,
                    password: password,
                },
                headers: {
                    'Content-Type': 'application/json',
                },
            })
            .then((response) => {
                console.log(response.data)
            })
            .catch((error) => {
                console.log(error)
            })
    })

The value of this req.url.slice(1) is http://localhost:38080/api/v5/configs/broker When I send an other axios request

        const proxyUrl = 'http://5c62ur.natappfree.cc/scros/';
        const targetUrl = 'http://5c62ur.natappfree.cc/mqtt/api/v5/configs/trace';

        axios
            .get(proxyUrl + targetUrl, {
                auth: {
                    username: username,
                    password: password,
                },
                headers: {
                    'Content-Type': 'application/json',
                },
            })
            .then((response) => {
                console.log(response.data)
            })
            .catch((error) => {
                console.log(error)
            })
    })

The value of this req.url.slice(1) is http:/5c62ur.natappfree.cc/mqtt/api/v5/configs/broker,There is a / missing after http:

bulk88 commented 9 months ago

You have a bug, with the cloudflare edge proxy, "normalizing", accidentally or intentionally, your URL. I think a patch I wrote and it was merged public to CORS-A fixed this parsing problem of "myapp.herokuapp.com/https:/foo.com/home"