【发布时间】:2019-10-06 23:35:41
【问题描述】:
尝试部署一个 vuejs,将应用程序快递到 heroku。该应用程序显示,但无法访问 api,因为 heroku 似乎在 base_url 中间添加了“未定义”。一切都按预期在本地运行。
这是我的 heroku 配置变量:
BASE_URL: https://goore-todos.herokuapp.com/
这里是 Vuejs 组件 api 请求:
fetchTodo () {
let uri = process.env.BASE_URL + '/api/all';
axios.get(uri).then((response) => {
this.todos = response.data;
});
},
如上所述,这在本地有效。
控制台显示以下错误: VM71:1 GET https://goore-todos.herokuapp.com/undefined/api/all 404(未找到)
视图是空的。
通过 Postman 向 https://goore-todos.herokuapp.com/api/ 发出的请求按预期工作。
【问题讨论】:
标签: express heroku environment-variables axios base-url