Docker网络:错误\u名称\u未\u使用FETCH API解析

Docker网络:错误\u名称\u未\u使用FETCH API解析,docker,api,containers,Docker,Api,Containers,奇怪的事情正在发生。我有一个docker结构: +------------------------+ +-------------------------+ | | | | | | | | | api_application | |

奇怪的事情正在发生。我有一个docker结构:

 +------------------------+       +-------------------------+
 |                        |       |                         |
 |                        |       |                         |
 |   api_application      |       |                         |
 |                        |       |   web_application       |
 |                        |       |                         |
 |                        |       |                         |
 |                        |       |                         |
 +------------------------+       +-------------------------+
                    |                      |
                    |                      |
                    |                      |
                    |                      |
                    +----------------------+
                               |
                               +
                         application_br
web\u应用程序-express.js
api_应用程序-烧瓶

我在search.html和app.js中使用了fetchapi,这是最后一次使用node_Fetch

app.js示例:

  (async () => {
    const body = req.body;
  
    const response = await fetch('http://api_application:5000/auth', {
      method: 'post',
      body: JSON.stringify(body),
      headers: {'Content-Type': 'application/json'}
    });
    const json = await response.json();
    if(typeof(json)=="object"){
      req.session.nome = json[0];
      console.log("Logged");
      res.redirect("/");
    }else if(typeof(json)=="string"){
        //Usuario Incorreto
        console.log("Failed");
        res.redirect('login');
    }
  })();
search.html:

<script>
fetch('http://api_application:5000/search/12345')
  .then(response => response.json())
  .then(data => console.log(data));
</script>

取('http://api_application:5000/search/12345')
.then(response=>response.json())
.then(data=>console.log(data));
节点_Fetch工作正常,取而代之的是Fetch API(Javascript),我收到以下错误:

搜索:114获取http://api_application:5000/search/52365 net::错误\u名称\u未\u解析

这没有意义,因为如果我在
web\u应用程序中执行bash并执行
curlhttp://api_application:5000/search/1233
我得到了json响应

容器之间的Ping-罚款 来自Web容器的Curl API-很好


FetchAPI中是否存在一些问题?我错在哪里?

浏览器中运行
search.html
内容;这在Docker之外,不能使用Docker的任何网络功能(包括按名称调用容器)。我应该使用node_fetch创建相同的函数,对吗?