1、请求地址:http://192.168.1.216:8080/renren-api/api/getUserInfo
2、修改 manifest.json
"h5": {"devServer": { "port": 5173, //端口号 "disableHostCheck": true, "proxy": { "/renren-api": { "target": "http://192.168.1.216:8080/", //目标接口域名 "changeOrigin": true, //是否跨域 "secure": false, // 设置支持https协议的代理 "pathRewrite": { "^/renren-api": "" //意思就是把devApi这个替换成空 '' } } } }
}
3、项目中请求
let apiBaseUrl='' //APP:APP端 /*#ifdef APP-PLUS*/ console.log('APP端') /*#endif*/ //H5:H5端 /*#ifdef H5*/ apiBaseUrl='/renren-api' /*#endif*/ //MP:小程序 /*#ifdef MP*/ apiBaseUrl='http://192.168.1.216:8081/renren-api' /*#endif*/ const config = { // apiBaseUrl:'http://192.168.1.216:8081/renren-api', // 线上 apiBaseUrl: apiBaseUrl, aMapWX_key: '816b36912b80694b8295a6053fd714a5' } // 请求地址 url: config.apiBaseUrl + url
标签:uniapp,http,跨域,renren,192.168,H5,apiBaseUrl,api From: https://www.cnblogs.com/hellowoeld/p/17559539.html