|
|
@@ -20,6 +20,7 @@ export type CommonProps = {
|
|
|
isContainerFluid: boolean,
|
|
|
growiVersion: string,
|
|
|
isMaintenanceMode: boolean,
|
|
|
+ redirectDestination: string | null,
|
|
|
} & Partial<SSRConfig>;
|
|
|
|
|
|
// eslint-disable-next-line max-len
|
|
|
@@ -34,6 +35,11 @@ export const getServerSideCommonProps: GetServerSideProps<CommonProps> = async(c
|
|
|
const url = new URL(context.resolvedUrl, 'http://example.com');
|
|
|
const currentPathname = decodeURI(url.pathname);
|
|
|
|
|
|
+ const isMaintenanceMode = appService.isMaintenanceMode();
|
|
|
+
|
|
|
+ // eslint-disable-next-line max-len, no-nested-ternary
|
|
|
+ const redirectDestination = !isMaintenanceMode && currentPathname === '/maintenance' ? '/' : isMaintenanceMode && !currentPathname.match('/admin/*') && !(currentPathname === '/maintenance') ? '/maintenance' : null;
|
|
|
+
|
|
|
const props: CommonProps = {
|
|
|
namespacesRequired: ['translation'],
|
|
|
currentPathname,
|
|
|
@@ -45,29 +51,10 @@ export const getServerSideCommonProps: GetServerSideProps<CommonProps> = async(c
|
|
|
csrfToken: req.csrfToken(),
|
|
|
isContainerFluid: configManager.getConfig('crowi', 'customize:isContainerFluid') ?? false,
|
|
|
growiVersion: crowi.version,
|
|
|
- isMaintenanceMode: appService.isMaintenanceMode(),
|
|
|
+ isMaintenanceMode,
|
|
|
+ redirectDestination,
|
|
|
};
|
|
|
|
|
|
- if (!props.isMaintenanceMode && currentPathname === '/maintenance') {
|
|
|
- return {
|
|
|
- props,
|
|
|
- redirect: {
|
|
|
- destination: '/',
|
|
|
- permanent: false,
|
|
|
- },
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- if (props.isMaintenanceMode && !currentPathname.match('/admin/*') && !(currentPathname === '/maintenance')) {
|
|
|
- return {
|
|
|
- props,
|
|
|
- redirect: {
|
|
|
- destination: '/maintenance',
|
|
|
- permanent: false,
|
|
|
- },
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
return { props };
|
|
|
};
|
|
|
|