Fix page props types (#565)

This commit is contained in:
Zoe Roux 2024-07-15 01:08:47 +07:00 committed by GitHub
parent 1f7443336e
commit 7209b7d0a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -47,7 +47,7 @@ export const withTranslations = (
...commonOptions,
lng: props.pageProps.__lang,
});
i18next.systemLanguage = props.pageProps.__sysLang;
i18next.systemLanguage = props.pageProps?.__sysLang;
return i18next;
});
@ -66,6 +66,7 @@ export const withTranslations = (
lng,
});
i18n.systemLanguage = sysLng;
props.pageProps ??= {};
props.pageProps.__lang = lng;
props.pageProps.__sysLang = sysLng;
return props;

View File

@ -264,12 +264,12 @@ App.getInitialProps = async (ctx: AppContext) => {
) {
ctx.ctx.res!.writeHead(307, { Location: `/setup?step=${info!.setupStatus}` });
ctx.ctx.res!.end();
return {} as any;
return { pageProps: {} };
}
if (info!.setupStatus === SetupStep.Done && ctx.router.route === "/setup") {
ctx.ctx.res!.writeHead(307, { Location: "/" });
ctx.ctx.res!.end();
return {} as any;
return { pageProps: {} };
}
} catch (e) {
console.error("SSR error, disabling it.");