1.环境配置如下:
module.exports = {
// 开发环境设置为根路径
publicPath: '/',
productionSourceMap: false,
filenameHashing: true,
// 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 ''
devServer: {
port: 80,
disableHostCheck: true,
proxy:{
'/api': {
target: 'http://ddemo.com/',
changeOrigin: true,
pathRewrite: {
'^/api': '/'
}
},
},
},
2.baselUrl设置为空
axios.defaults.baseURL = ''
3.使用时不带前缀
return http.post('/api/coinRpcService/getCoinCount', data, reqPayload, true)
4.本地访问的时候不提示跨域,提示接口404,后端单独可以访问到这个接口。
回答需要的截图。
找不出问题在哪。。
'http://ddemo.com/
改成https://www.lilnong.top/cors/
试试。