Axios仅使用“ heroku本地网络”具有错误的URL

时间:2020-01-27 19:59:23

标签: vue.js heroku axios

我遇到了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 ...

有解决方案吗?

1 个答案:

答案 0 :(得分:0)

这很尴尬,我有一个类型:

http://而不是http //:

请参阅:Quasar Axios request wrong URL (Double URL)