Wednesday, January 12, 2022

docker: Angular client fails to call web service on docker


 >PROBLEM


You've have an Angular project that uses a web services, for instance Java Spring Boot, that works on the environment that is was created, but when the projects (the client and the WS) are migrated to Docker containers, they fail to communicate.

>SOLUTION


If the usual call using localhost fails, replace it with “host.docker.internal”.

  // usual, outside docker
  //private serverUrl = 'http://localhost:8081'

  // docker, if it fails localhost
  private serverUrl = 'http://host.docker.internal:8080'


Detailed procedure here:

>ENV

Windows 10
Docker
Angular 7..13
Node.js 12..16

No comments:

Post a Comment

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...