Fixed path for loading resource bundles (#3074)

This commit is contained in:
Erik Jan de Wit 2022-08-09 11:39:38 +02:00 committed by GitHub
parent 09d7194f9b
commit 108f4048bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import environment from "./environment"; import environment from "./environment";
import { getAuthorizationHeaders } from "./utils/getAuthorizationHeaders"; import { getAuthorizationHeaders } from "./utils/getAuthorizationHeaders";
import { addTrailingSlash } from "./util";
export const DEFAULT_LOCALE = "en"; export const DEFAULT_LOCALE = "en";
@ -18,7 +19,9 @@ const initOptions = async (
): Promise<InitOptions> => { ): Promise<InitOptions> => {
const constructLoadPath: LoadPathOption = (_, namespaces) => { const constructLoadPath: LoadPathOption = (_, namespaces) => {
if (namespaces[0] === "overrides") { if (namespaces[0] === "overrides") {
return `/admin/realms/${adminClient.realmName}/localization/{{lng}}?useRealmDefaultLocaleFallback=true`; return `${addTrailingSlash(adminClient.baseUrl)}admin/realms/${
adminClient.realmName
}/localization/{{lng}}?useRealmDefaultLocaleFallback=true`;
} else { } else {
return `${environment.resourceUrl}/resources/{{lng}}/{{ns}}.json`; return `${environment.resourceUrl}/resources/{{lng}}/{{ns}}.json`;
} }