您的当前位置:首页>全部文章>文章详情

uniapp跨域解决方案

发表于:2023-09-09 09:23:46浏览:100次TAG: #uniapp

在 mainfest.json 文件中的 {} 中添加如下代码:

"h5":{
    "devServer":{
        "port":8080,
        "disableHostCheck":true,
        "proxy":{
            "/api":{
                "target":"http://localhost:80",
                "changeOrigin":true,
                "secure":false,
                "pathRewrite":{
                    "/api":""
                }
            }
        }
    }
}

说明:假设是使用 phpstudy 运行的 http://localhost:80