http请求失败,求解决

代码如下
get(url, params, callback) {
        var xhr = cc.loader.getXMLHttpRequest();
        xhr.timeout = 5000;
        var requestURL = url;
        // if (params) {
        //     requestURL = requestURL + "?" + params;
        // }
        
        xhr.open("GET",requestURL, true);
        if (cc.sys.isNative){
            xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
        }
        xhr.setRequestHeader("Content-Type" , "application/json");
        // xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

        xhr.onreadystatechange = function() {
            if(xhr.readyState === 4){
                if(xhr.status >= 200 && xhr.status < 300){
                    callback && callback(JSON.parse(xhr.response));
                }
                else {
                    callback && callback(null);
                }
            }
        };
        
        xhr.send(params);
        return xhr;
    }

在浏览器模式中调试提示
Access to XMLHttpRequest at ‘https://www.baidu.com/’ from origin ‘http://localhost:7456’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: Redirect is not allowed for a preflight request.

后端已修改header “Access-Control-Allow-Origin”,"*"还是不行

localhost 改成ip

还是没用啊,我的一个可以,一个不可以

可以用我这个
https://github.com/Hansen-hjs/my-note/blob/master/JavaScript/js/ajax.js