uniapp生成H5页面,网络请求报跨域错误,但是后台已经设置了跨域,用代理转发都不行。本地配置代理也不行。哪个大老知道问题啊,帮帮忙,我都快疯了,postmain 请求正常,浏览器地址打开也正常。内置浏览器打开也正常,就是运行成h5,打包成H5不行。
<template>  
    <view>  
        <view class="qbtn">  
            <text class="btn-text-color fs30" @click="login">登录</text>  
        </view>  
    </view>  
</template>  
<script>  
    export default {  
        data() {  
            return {}  
        },  
        methods: {  
            login() {  
                uni.request({  
                    // url: '/newapp2/upms/rest/upms/user/getByLoginName/13123456789',  
                    url: 'https://grid.szhgy.cn/upms/rest/upms/user/getByLoginName/13123456789',  
                    data: '',  
                    method: 'POST',  
                    success: (res) => {}  
                });  
            }  
        }  
    }  
</script>  
本地配置跨域后不起作用 newapp1接口"h5" : {  
        "title" : "花**",  
        "template" : "",  
        "router" : {  
            "base" : "./"  
        },  
        "devServer" : {  
            "port" : "8080", //端口号  
            "disableHostCheck" : true,  
            "proxy" : {  
                "/newapp1" : {  
                    "target" : "https://index.szhgy.cn", //自己项目接口域名  
                    "changeOrigin" : true, //是否跨域  
                    "secure" : true, // 设置支持https协议的代理  
                    "pathRewrite" : {  
                        "^/newapp1" : "/"  
                    }  
                },  
                "/newapp2" : {  
                    "target" : "https://grid.szhgy.cn", //自己项目接口域名  
                    "changeOrigin" : true, //是否跨域  
                    "secure" : true, // 设置支持https协议的代理  
                    "pathRewrite" : {  
                        "^/newapp2" : "/"  
                    }  
                }  
            },  
            "https" : false  
        },  
        "optimization" : {  
            "treeShaking" : {  
                "enable" : true  
            }  
        }  
    } 
             
             
             
			 
                                        
                                    
 
                                                                     
                                                                     
                                                                    
 
            
开发猿
请问一下,在manifest.json中配h5代理,target可以识别到,pathRewrite识别不了,是因为啥啊
2022-09-20 10:29