@@ -27,6 +27,7 @@ import { Spinner } from '@patternfly/react-core/dist/dynamic/components/Spinner'
2727import UserMenu from './UserMenu/UserMenu' ;
2828import { useSession } from 'next-auth/react' ;
2929import { useTheme } from '../context/ThemeContext' ;
30+ import { useState } from 'react' ;
3031
3132interface IAppLayout {
3233 children : React . ReactNode ;
@@ -41,9 +42,21 @@ type Route = {
4142const AppLayout : React . FunctionComponent < IAppLayout > = ( { children } ) => {
4243 const { theme } = useTheme ( ) ;
4344 const { data : session , status } = useSession ( ) ;
45+ const [ isExperimentalEnabled , setExperimental ] = useState ( false ) ;
46+
4447 const router = useRouter ( ) ;
4548 const pathname = usePathname ( ) ;
4649
50+ React . useEffect ( ( ) => {
51+ // Fetch the experimental feature flag
52+ const fetchExperimentalFeature = async ( ) => {
53+ const res = await fetch ( '/api/envConfig' ) ;
54+ const envConfig = await res . json ( ) ;
55+ setExperimental ( envConfig . EXPERIMENTAL_FEATURES === 'true' ) ;
56+ } ;
57+ fetchExperimentalFeature ( ) ;
58+ } , [ ] ) ;
59+
4760 React . useEffect ( ( ) => {
4861 if ( status === 'loading' ) return ; // Do nothing while loading
4962 if ( ! session && pathname !== '/login' ) {
@@ -59,7 +72,7 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
5972 return null ; // Return nothing if not authenticated to avoid flicker
6073 }
6174
62- const isExperimentalEnabled = process . env . NEXT_PUBLIC_EXPERIMENTAL_FEATURES === 'true' ;
75+ // const isExperimentalEnabled = process.env.NEXT_PUBLIC_EXPERIMENTAL_FEATURES === 'true';
6376
6477 // Only log if experimental features are enabled
6578 if ( isExperimentalEnabled ) {
0 commit comments