@@ -9,9 +9,10 @@ import { ModalsProvider } from "@mantine/modals";
9
9
import { Notifications } from "@mantine/notifications" ;
10
10
import axios from "axios" ;
11
11
import { getCookie , setCookie } from "cookies-next" ;
12
+ import moment from "moment" ;
13
+ import "moment/min/locales" ;
12
14
import { GetServerSidePropsContext } from "next" ;
13
15
import type { AppProps } from "next/app" ;
14
- import getConfig from "next/config" ;
15
16
import Head from "next/head" ;
16
17
import { useRouter } from "next/router" ;
17
18
import { useEffect , useRef , useState } from "react" ;
@@ -29,8 +30,6 @@ import Config from "../types/config.type";
29
30
import { CurrentUser } from "../types/user.type" ;
30
31
import i18nUtil from "../utils/i18n.util" ;
31
32
import userPreferences from "../utils/userPreferences.util" ;
32
- import "moment/min/locales" ;
33
- import moment from "moment" ;
34
33
35
34
const excludeDefaultLayoutRoutes = [ "/admin/config/[category]" ] ;
36
35
@@ -44,7 +43,7 @@ function App({ Component, pageProps }: AppProps) {
44
43
const [ route , setRoute ] = useState < string > ( pageProps . route ) ;
45
44
46
45
const [ configVariables , setConfigVariables ] = useState < Config [ ] > (
47
- pageProps . configVariables ,
46
+ pageProps . configVariables
48
47
) ;
49
48
50
49
useEffect ( ( ) => {
@@ -54,7 +53,7 @@ function App({ Component, pageProps }: AppProps) {
54
53
useEffect ( ( ) => {
55
54
const interval = setInterval (
56
55
async ( ) => await authService . refreshAccessToken ( ) ,
57
- 2 * 60 * 1000 , // 2 minutes
56
+ 2 * 60 * 1000 // 2 minutes
58
57
) ;
59
58
60
59
return ( ) => clearInterval ( interval ) ;
@@ -154,8 +153,6 @@ function App({ Component, pageProps }: AppProps) {
154
153
// Fetch user and config variables on server side when the first request is made
155
154
// These will get passed as a page prop to the App component and stored in the contexts
156
155
App . getInitialProps = async ( { ctx } : { ctx : GetServerSidePropsContext } ) => {
157
- const { apiURL } = getConfig ( ) . serverRuntimeConfig ;
158
-
159
156
let pageProps : {
160
157
user ?: CurrentUser ;
161
158
configVariables ?: Config [ ] ;
@@ -169,6 +166,7 @@ App.getInitialProps = async ({ ctx }: { ctx: GetServerSidePropsContext }) => {
169
166
} ;
170
167
171
168
if ( ctx . req ) {
169
+ const apiURL = process . env . API_URL || "http://localhost:8080" ;
172
170
const cookieHeader = ctx . req . headers . cookie ;
173
171
174
172
pageProps . user = await axios ( `${ apiURL } /api/users/me` , {
@@ -182,7 +180,7 @@ App.getInitialProps = async ({ ctx }: { ctx: GetServerSidePropsContext }) => {
182
180
pageProps . route = ctx . req . url ;
183
181
184
182
const requestLanguage = i18nUtil . getLanguageFromAcceptHeader (
185
- ctx . req . headers [ "accept-language" ] ,
183
+ ctx . req . headers [ "accept-language" ]
186
184
) ;
187
185
188
186
pageProps . language = ctx . req . cookies [ "language" ] ?? requestLanguage ;
0 commit comments