1.描述问题:
我现在的目的是通过配置proxyTable,解决跨域问题,不用后台改接口了(项目原来是jquery做的,现在用vue改造)。我按要求写了配置文件:
请求的url代码:
现在浏览器报错,么有数据返回。:
接口正常访问没问题,接口所在的服务器地址是http://localhost:8080/Persona...
webpack的启动服务器地址是localhost:8090
有大神遇到这个问题吗?如何解决的?
1.描述问题:
我现在的目的是通过配置proxyTable,解决跨域问题,不用后台改接口了(项目原来是jquery做的,现在用vue改造)。我按要求写了配置文件:
请求的url代码:
现在浏览器报错,么有数据返回。:
接口正常访问没问题,接口所在的服务器地址是http://localhost:8080/Persona...
webpack的启动服务器地址是localhost:8090
有大神遇到这个问题吗?如何解决的?
没有那么复杂。
假设真正的url是:http://localhost:10080/api/xx...
只需要'/api': 'http://localhost:10080'
就行
下面是我的proxyTable:
proxyTable: {
'/schema': 'http://localhost:10080',
'/api': 'http://localhost:10080'
},
proxyTable: {
'/o2o': {
target: 'http://10.16.10.142:8081/o2o',
changeOrigin: true
}
}
保证target后缀跟你设置的名字一致
建议target写成:"http://ip地址/xx/xx",尽量不要用localhost,node开发时有问题