diff --git a/src/core/components/Config.jsx b/src/core/components/Config.jsx
new file mode 100644
index 0000000..3c1d833
--- /dev/null
+++ b/src/core/components/Config.jsx
@@ -0,0 +1,28 @@
+import {useEffect, useState} from "react";
+import axios from "axios";
+import {GET_CONFIG} from "@/core/data/apiRoutes";
+import {ConfigProvider} from "@witel/webapp-builder";
+
+const ConfigApp = ({children}) => {
+ const [error, setError] = useState(false)
+ const [config, setConfig] = useState()
+
+ useEffect(() => {
+ const fetchConfig = async () => {
+ try {
+ const response = await axios(GET_CONFIG)
+ setConfig(response.data)
+ } catch (error) {
+ setError(true)
+ }
+ }
+
+ fetchConfig()
+
+ }, []);
+
+ return (
+ {error ? <>Error request config> : config && children})
+}
+
+export default ConfigApp
\ No newline at end of file
diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js
index 69d7e64..f2e42fc 100644
--- a/src/core/data/apiRoutes.js
+++ b/src/core/data/apiRoutes.js
@@ -1,5 +1,7 @@
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL + "/api";
+export const GET_CONFIG = process.env.NEXT_PUBLIC_CONFIG_APP_URL;
+
// export const LOGIN_SEND_OTP_TOKEN = BASE_URL + "/login/send_otp";
export const LOGIN = BASE_URL + "/login";
// export const REGISTER_SEND_OTP_TOKEN = BASE_URL + "/register/send_otp";
diff --git a/src/core/utils/globalServerProps.js b/src/core/utils/globalServerProps.js
index 107efee..422a77b 100644
--- a/src/core/utils/globalServerProps.js
+++ b/src/core/utils/globalServerProps.js
@@ -1,13 +1,9 @@
import {parse} from "next-useragent";
-import process from "next/dist/build/webpack/loaders/resolve-url-loader/lib/postcss";
export const globalServerProps = async ({req, locale}) => {
const {isBot} = parse(req.headers["user-agent"]);
-
- const responseConfig = await fetch(`${process.env.NEXT_PUBLIC_CONFIG_APP_URL}?_=${Math.random()}`);
return {
- config: await responseConfig.json(),
messages: (await import(`&/locales/${locale}/app.json`)).default,
isBot,
locale,
diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx
index 848a35c..e2f97b1 100644
--- a/src/pages/_app.jsx
+++ b/src/pages/_app.jsx
@@ -2,7 +2,6 @@ import "&/global.scss";
import "moment/locale/fa";
import {
AppLayout,
- ConfigProvider,
LanguageProvider,
LoadingProvider,
MuiLayout,
@@ -18,10 +17,11 @@ import themeRtl from "@/core/utils/theme-rtl";
import TitlePage from "@/core/components/TitlePage";
import GlobalHead from "@/core/components/GlobalHead";
import Layout from "@/layouts";
+import ConfigApp from "@/core/components/Config";
const App = ({Component, pageProps}) => {
return (<>
-
+
data}>
@@ -45,7 +45,7 @@ const App = ({Component, pageProps}) => {
-
+
>);
};