Skip to content

Commit 712291c

Browse files
authored
🐛 Only load keycloak when AUTH_REQUIRED is "true" (#1616)
Only add the actual `AuthEnabledKeycloakProvider` keycloak handler if the `AUTH_REQUIRED` environment variable is set `"true"`. Signed-off-by: Scott J Dickerson <[email protected]>
1 parent eea7835 commit 712291c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

client/src/app/components/KeycloakProvider.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@ import { ReactKeycloakProvider } from "@react-keycloak/web";
33
import keycloak from "@app/keycloak";
44
import { AppPlaceholder } from "./AppPlaceholder";
55
import { initInterceptors } from "@app/axios-config";
6+
import ENV from "@app/env";
67

78
interface IKeycloakProviderProps {
89
children: React.ReactNode;
910
}
1011

1112
export const KeycloakProvider: React.FC<IKeycloakProviderProps> = ({
1213
children,
14+
}) => {
15+
return ENV.AUTH_REQUIRED !== "true" ? (
16+
<>{children}</>
17+
) : (
18+
<AuthEnabledKeycloakProvider>{children}</AuthEnabledKeycloakProvider>
19+
);
20+
};
21+
22+
const AuthEnabledKeycloakProvider: React.FC<IKeycloakProviderProps> = ({
23+
children,
1324
}) => {
1425
React.useEffect(() => {
1526
initInterceptors();

0 commit comments

Comments
 (0)