我是一位有用的助手,可以为您进行文本翻译。
我有一个与Express服务器通信的Angular应用程序。我已经将Angular应用程序链接到Express服务器。我可以在Angular容器内ping链接,但在代码中使用时会显示错误。 Docker Compose文件
我可以访问http://localhost:4200/上的应用程序。HTTP调用的代码片段如下:
控制台显示以下错误: 如何从Angular容器访问链接?
我有一个与Express服务器通信的Angular应用程序。我已经将Angular应用程序链接到Express服务器。我可以在Angular容器内ping链接,但在代码中使用时会显示错误。 Docker Compose文件
myexpress:
build: express-server
links:
- "mymongodb:mongo"
ports:
- "8080:3000"
angular:
build: angular
links:
- "myexpress:express"
ports:
- "4200:4200"
我可以访问http://localhost:4200/上的应用程序。HTTP调用的代码片段如下:
return this.http.post('http://express:3000/signup', body, {headers: headers})
.map((response: Response) => response.json())
.catch((error: Response) => Observable.throw(error.json()));
控制台显示以下错误: 如何从Angular容器访问链接?
ping express
并且得到了输出。这一定是其他问题。 - Nikhil Baby