Token not received inside Docker with Express JS
-
After adding a authentication layer between Angular and Express JS, I successfully tested the architecture using the 3 servers i.e. Angular, Express JS and Fusionauth. All are working fine.
When all the setup was moved to docker compose file, I am facing a problem when fusionauth is calling the express JS server - http://localhost:3000/oauth-callback.
Undefined is returned in the body, hence no token is received. As stated earlier, when tried with Express JS as a separate server and not in the docker file ( Angular and Fusionauth in docker-compose and Express JS as a separate server ) , it is working fine.
My question, is there any docker configuration required with Express JS server ?
Docker Configuration of ExpressJS -
fusionexpressjs:
image: fusionexpressjs
ports:
- 3000:3000 -
Without understanding your setup completely, is the callback happening in a server-to-server call? If so, localhost doesn't work.
For example when I wanna call the elastic search container from fusion auth, I cannot call it as http://localhost:9200. For instance if the setup is
fusionauth-search: image: docker.elastic.co/elasticsearch/elasticsearch:8.5.0 container_name: fusionauth-search environment: cluster.name: fusionauth networks: - data-layer restart: unless-stopped ports: - '9011:9011'
I will need to call it via
http://fusionauth-search:9200
. You can also see such a setup in Fusion Auth's documentation on setting up Fusion Auth in docker-compose at https://fusionauth.io/docs/v1/tech/installation-guide/docker. You notice that the URLs will refer to the container names.I hope this helps.