Nuxt.js与Flask的连接被拒绝。糟糕的路线?

2024-04-18 08:31:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经尝试根据this教程将我的Flask服务器连接到nuxt.js。我已经创建了一个环境变量env:

{
    HOST_URL: process.env.HOST_URL || 'http://127.0.0.1:5000'
  }, 

并将其与axios连接到我的索引文件中

import axios from '~/node_modules/axios'
export default {
    async asyncData () {
      let {data} = await axios.get('/')
      console.log(data.data)
      return data.data
    },

当我尝试运行教程中描述的项目时,一切正常。 当我对自己的nubies代码做同样的事情时,我得到了这个错误

enter image description here

如果我输入与服务器的直接链接,如axios.get('http://localhost:5000/').

在我看来,在我的代码(我用webpack simple初始化)的某个地方,路由更改为http://localhost:80 有没有办法解决这个问题


Tags: 代码服务器envlocalhosthttphosturlflask