Skip to content

API domain name resolution problem #461

@MATACE

Description

@MATACE

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions