Node.js 在将应用程序部署到Heroku后,API_URL配置变量被我当前应用程序的URL前置,从而导致错误的请求URL

Node.js 在将应用程序部署到Heroku后,API_URL配置变量被我当前应用程序的URL前置,从而导致错误的请求URL,node.js,reactjs,express,heroku,create-react-app,Node.js,Reactjs,Express,Heroku,Create React App,我在Heroku上运行两个独立的应用程序(创建react应用程序前端和一个node/express后端)。我正在尝试从info-screen.herokuapp.com向info-screen后端发送请求 这是GET请求处理程序: app.get('/info', (req, res) => { Info.find() .then( info => { res.status(200).json(info) }) .catch( err

我在Heroku上运行两个独立的应用程序(创建react应用程序前端和一个node/express后端)。我正在尝试从info-screen.herokuapp.com向info-screen后端发送请求

这是GET请求处理程序:

app.get('/info', (req, res) => {
    Info.find()
    .then( info => {
        res.status(200).json(info)
    })
    .catch( err => {
        res.status(404).json({
            message: err
        });
    });
});
在这里,您可以看到实际发送请求的前端:

 axios.get(API_URI + '/info')
    .then( (resp) => {
      console.log(resp);
    })
    .catch( (err) => {
      console.log(err);
    })
以下是API_URI env变量的配置变量:

我已经找了两个小时了

每当我发送请求时,出于某种原因,前端会尝试在API_URI变量前面加上它自己的URI,结果是(查看请求URL):

这里有没有人有过这样的经历?我试着在谷歌上搜索一下,我想也许CreateReact应用程序使用的是BaseUrl之类的东西,但显然不是

当我直接向API发送请求时,它通常会返回:

[
  {
    "created_by": "Innkaupadeild",
    "show": false,
    "_id": "5e67b5b4070f000004a62c79",
    "title": "New shipment on hold",
    "details": "New shipment on testing 2",
    "created_date": "2020-03-10T15:43:48.710Z",
    "modified_date": "2020-03-10T15:43:48.710Z",
    "__v": 0
  }
]
这意味着这肯定是在前端网站

我是否缺少package.json中的某些内容,或者是否需要另一个文件来允许heroku发出外部请求


如果API_URI不是
https://info-screen.herokuapp.com
可能只是因为图像剪切了部分值,但是如果API URI不是
https://info-screen.herokuapp.com
可能是仅仅因为图像剪切了部分值,但在键入的文本中,您也省略了url的协议部分!真不敢相信我在这件事上浪费了这么多时间就为了这个。请把这个问题的答案写下来,这样我才能把它标为正确。