为了账号安全,请及时绑定邮箱和手机立即绑定

本地启动两个项目,调取另一个node项目的数据接口,跨域了

本地启动两个项目,调取另一个node项目的数据接口,跨域了

森栏 2018-11-21 18:13:24
本地启动两个项目,一个是vue cli项目在8080端口,一个是node数据接口项目在4000端口,现在我想调用4000端口的接口数据,跨域了。这是我在8080端口vue项目写的一个代理dev: {    env: require('./dev.env'),    port: 8080,    autoOpenBrowser: true,    assetsSubDirectory: 'static',    assetsPublicPath: '/',    proxyTable: {        '/api': {            target: 'http://192.168.1.43:4000',            changeOrigin: true,            pathRewrite: {                '^/api': ''            }        }    },现在我需要用axios获取4000端口的数据getData() {    let _this = this;    _this.axios.get('/api/playlist/detail',{'id':24381616})        .then(function(res) {            _this.listdata = res;        })        .catch(function (res) {            console.log(res)        })}一直报跨域错误
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 691 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信