We are having the same issue. Our current setup is…
- React application using NextJS
- Standalone Keycloak server
We have set things up with the default settings using an Authorization Code Flow.
When we use the keycloak-js library to call keycloak.login(), it directs to Keycloak correctly. But, if the user clicks the Back button in the browser, they are not taken to the previous page, but to the the page that was in the browser history before the previous page.
I have a feeling that the keycloak-js library is re-writing the browser history.
This also happens if we call keycloak.register().
I have not found a workaround yet. Would like to hear from the keycloak-js team about this.