'Keycloak not initializing in React when deployed to Docker

I am using Keycloak as authentication in my React Web Application. When ran in local, it is working properly. But when already deployed in Docker, Keycloak does not initialize.

Here is my Keycloak init code:

componentDidMount() {
    const keycloak = Keycloak("/keycloak-dev.json");
    keycloak.init({onLoad: 'login-required'}).then(authenticated => {
      this.setState({ keycloak: keycloak, authenticated: authenticated, roles: keycloak?.tokenParsed?.realm_access?.roles, token: keycloak.token})
    })
  }

/keycloak-dev.json is in the public folder of my application.

Does anyone know what the problem is?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source