diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java index 2b796c54e0..4f50397cb5 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java @@ -296,6 +296,7 @@ public class AdminConsole { authUrl = authUrl.substring(0, authUrl.length() - 1); map.put("authUrl", authUrl); + map.put("consoleBaseUrl", uriInfo.getRequestUri().toString()); map.put("resourceUrl", Urls.themeRoot(baseUri) + "/admin/" + theme.getName()); map.put("masterRealm", Config.getAdminRealm()); map.put("resourceVersion", Version.RESOURCES_VERSION); diff --git a/themes/src/main/resources/theme/base/admin/index.ftl b/themes/src/main/resources/theme/base/admin/index.ftl index 82150bc40d..771790465c 100755 --- a/themes/src/main/resources/theme/base/admin/index.ftl +++ b/themes/src/main/resources/theme/base/admin/index.ftl @@ -17,6 +17,7 @@ diff --git a/themes/src/main/resources/theme/base/admin/resources/js/app.js b/themes/src/main/resources/theme/base/admin/resources/js/app.js index ad0b5e9d5f..c4a134b057 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/app.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/app.js @@ -1,10 +1,5 @@ 'use strict'; -var consoleBaseUrl = window.location.href; -consoleBaseUrl = consoleBaseUrl.substring(0, consoleBaseUrl.indexOf("/console")); -consoleBaseUrl = consoleBaseUrl + "/console"; -var configUrl = consoleBaseUrl + "/config"; - var auth = {}; var resourceBundle; var locale = 'en'; @@ -14,11 +9,11 @@ var resourceRequests = 0; var loadingTimer = -1; angular.element(document).ready(function () { - var keycloakAuth = new Keycloak(configUrl); + var keycloakAuth = new Keycloak(consoleBaseUrl + 'config'); function whoAmI(success, error) { var req = new XMLHttpRequest(); - req.open('GET', consoleBaseUrl + "/whoami", true); + req.open('GET', consoleBaseUrl + 'whoami', true); req.setRequestHeader('Accept', 'application/json'); req.setRequestHeader('Authorization', 'bearer ' + keycloakAuth.token); @@ -38,7 +33,7 @@ angular.element(document).ready(function () { function loadResourceBundle(success, error) { var req = new XMLHttpRequest(); - req.open('GET', consoleBaseUrl + '/messages.json?lang=' + locale, true); + req.open('GET', consoleBaseUrl + 'messages.json?lang=' + locale, true); req.setRequestHeader('Accept', 'application/json'); req.onreadystatechange = function () {