mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 12:14:46 -04:00
Fix theme error on ssr
This commit is contained in:
parent
b6d122e449
commit
64031668c1
@ -210,6 +210,7 @@ App.getInitialProps = async (ctx: AppContext) => {
|
||||
|
||||
if (typeof window !== "undefined") return { pageProps: superjson.serialize(appProps.pageProps) };
|
||||
|
||||
try {
|
||||
const getUrl = Component.getFetchUrls;
|
||||
const getLayoutUrl =
|
||||
Component.getLayout && "Layout" in Component.getLayout
|
||||
@ -240,7 +241,9 @@ App.getInitialProps = async (ctx: AppContext) => {
|
||||
}
|
||||
}
|
||||
appProps.pageProps.theme = readCookie(ctx.ctx.req?.headers.cookie, "theme") ?? "auto";
|
||||
|
||||
} catch (e) {
|
||||
console.error("SSR error, disabling it.");
|
||||
}
|
||||
return { pageProps: superjson.serialize(appProps.pageProps) };
|
||||
};
|
||||
|
||||
|
@ -62,8 +62,7 @@ export const readCookie = <T extends ZodTypeAny>(
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
const str = c.substring(name.length, c.length);
|
||||
const ret = JSON.parse(str);
|
||||
return parser ? parser.parse(ret) : ret;
|
||||
return parser ? parser.parse(JSON.parse(str)) : str;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user