Errors when deploying axios app on Firebase (Vue.JS)

I have deployed my web app iPreformatted textn Vue.JS with Firebase.

I changed the URL from this line:

                fetch("http://localhost:1337/mail/login", requestOptions)

to the address of my domain name:

                fetch("http://[------------]/mail/login", requestOptions)
```,
because CORS will not allow data to be read in my firebase domain name. I can get the data from the local domain, not the firebase domain, so I changed the fetch URL. But after I done this, I get this error:
> DevTools failed to load source map: Could not parse content. Unexpected token < in JSON at position 0
,
and it came from this line: const userInfo = JSON.parse(result);

What should be done to fix this?

Part of my code file:
        getUserData: function () {
            var myHeaders = new Headers();
            myHeaders.append("Content-Type", "application/json");
            myHeaders.append("Cookie", ".AspNetCore.Session=[----------------]);
            ////console.log(Object.keys(myHeaders).length);
            var raw = JSON.stringify({
                "mail": this.mail,
                "password": this.password
            });

            var requestOptions = {
                method: 'POST',
                headers: myHeaders,
                body: raw,
                redirect: 'follow'
            };

            fetch("http://localhost:1337/mail/login", requestOptions)
                .then(response => response.text())
                .then(result => {
                    console.log(result)
                    const userInfo = JSON.parse(result);
                    //console.log(result)
                    //console.log(userInfo["sysCode"])
                    if (userInfo["sysCode"] == 2000) {

                        if (userInfo["data"].gender == 111)
                            this.user.gender = "Female"
                        else if (userInfo["data"].gender == 222)
                            this.user.gender = "Male"
                        else if (userInfo["data"].gender == 333)
                            this.user.gender = "Unstated"

                        this.user.firstName = userInfo["data"].firstName;
                        this.user.lastName = userInfo["data"].lastName;
                    }
                    else {
                        this.sysMsg = "User not found.";
                    }
                })
                .catch(error => console.log('error', error));

This is my vue.config.js:
devServer:
{
    proxy: {
        '/mail/login': {
            target: '[redacted, private domain]',
        },
        '/report/list': {
            target: '[redacted, private domain]',
        }
    }
}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.