我遇到了axios和heroku的问题。也许之前很短introduction。
CORS的问题已解决,我的应用程序在localhost和herokuapp.com上运行。当前唯一不起作用的是我的应用运行在heroku local web
上。
对于后端调用,我使用axios从环境文件中引用我的后端api:
axios
.get(process.env.VUE_APP_ROOT_API + "/resource")
.then(response => (this.receipt = response.data));
}
.env.local
:
VUE_APP_ROOT_API=http//:0.0.0.0:5002 #5002 is my backend
这会产生以下错误的axios调用:
GET http://0.0.0.0:5001/http//:0.0.0.0:5002/resource #5001 is my frontend
我无法解释该GET是如何生成的。使用
打印出请求网址axios.interceptors.request.use(request => {
console.log("Starting Request", request);
return request;
});
显示正确的URL http//:0.0.0.0:5002/resource
...
有解决方案吗?