fix: keycloak login handles base urls
MODIFY
src/app/guards/auth.guard.ts
src/app/guards/auth.guard.ts
@@ -30,9 +30,9 @@ export class AuthGuard extends KeycloakAuthGuard {
state: RouterStateSnapshot
): Promise<boolean | UrlTree> {
if (!this.authenticated) {
- console.log('Login required');
+ const url = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + state.url;
await this.keycloakAngular.login({
- redirectUri: window.location.origin + state.url,
+ redirectUri: url,
});
} else {
// we are logged in and can set the tokens

MODIFY
src/app/services/keycloak-helper/keycloak-helper.service.ts
src/app/services/keycloak-helper/keycloak-helper.service.ts
@@ -56,7 +56,8 @@ export class KeycloakHelperService {
public logout(): void {
KeycloakHelperService.clearTokensFromSessionStorage();
- this.keycloak.logout(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/home`)
+ const url = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + '/home';
+ this.keycloak.logout(url);
}
/**

fix: keycloak login handles base urls