高德接口-前端本地开发调用代理
请求中api:
export function jPAmapApi(data) {
return request({
url: '/v4/grasproad/driving?key=b03c9b62740951fd7fb9bba7f5be1c4f',
method: 'post',
data: data,
headers: {'content-type':'application/json','Access-Control-Allow-Origin': '*'}
})
}
其中 process.env.VUE_APP_BASE_API = /dev-api
vue.config.js:
devServer: {
host: '0.0.0.0',
port: port,
open: true,
proxy: {
'/dev-api/v4': {
target: `https://restapi.amap.com`,//高德api开发
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
}
}
}
正式环境外部接口(高德接口)代理请看下一篇