I'm using Spring Boot, Angular and Keycloak are dockerized in own containers in same network.
The issuer-uri in spring-boot backend is http://keycloak:8080/realms/sales and the
iss from decoded JWT token is http://localhost:8082/realms/sales.
Problem: My browser cannot use docker network hostnames. I have to use localhost to access keycloak.
I tried KEYCLOAK_FRONTEND_URL and other env variables, but did not fix my problem.
Anyone know how to make iss on both the same in this scenario?
This is a typical problem when moving from your pc - all localhost services - to dockerized environment.
The best and correct approach is to get a domain name for your keycloak instance and refer to the auth url as https://mykeycloak.something.com so the issuer is always this.
Another approach, but similar is to refer by the IP of the machine, so something like http://192.168.x.x:8082/realms/sales
EDIT: you should not go to production with a machine IP as issuer...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With