Shun Miyazawa 3 лет назад
Родитель
Сommit
705dc9c1a0
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      packages/app/src/pages/maintenance.page.tsx

+ 14 - 3
packages/app/src/pages/maintenance.page.tsx

@@ -20,8 +20,8 @@ type Props = CommonProps & {
 };
 
 const MaintenancePage: NextPage<CommonProps> = (props: Props) => {
-
   const { t } = useTranslation();
+
   useCurrentUser(props.currentUser ?? null);
 
   const logoutHandler = async() => {
@@ -83,14 +83,25 @@ async function injectNextI18NextConfigurations(context: GetServerSidePropsContex
 export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
   const req = context.req as CrowiRequest<IUserHasId & any>;
 
-  const { user } = req;
-  const result = await getServerSideCommonProps(context);
+  const { crowi } = req;
+  const isMaintenanceMode = crowi.appService.isMaintenanceMode();
+  if (!isMaintenanceMode) {
+    return {
+      redirect: {
+        destination: '/',
+        permanent: false,
+      },
+    };
+  }
 
+  const result = await getServerSideCommonProps(context);
   if (!('props' in result)) {
     throw new Error('invalid getSSP result');
   }
+
   const props: Props = result.props as Props;
 
+  const { user } = req;
   if (user != null) {
     props.currentUser = user.toObject();
   }