mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 20:54:13 -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) };
|
if (typeof window !== "undefined") return { pageProps: superjson.serialize(appProps.pageProps) };
|
||||||
|
|
||||||
|
try {
|
||||||
const getUrl = Component.getFetchUrls;
|
const getUrl = Component.getFetchUrls;
|
||||||
const getLayoutUrl =
|
const getLayoutUrl =
|
||||||
Component.getLayout && "Layout" in Component.getLayout
|
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";
|
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) };
|
return { pageProps: superjson.serialize(appProps.pageProps) };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,8 +62,7 @@ export const readCookie = <T extends ZodTypeAny>(
|
|||||||
}
|
}
|
||||||
if (c.indexOf(name) == 0) {
|
if (c.indexOf(name) == 0) {
|
||||||
const str = c.substring(name.length, c.length);
|
const str = c.substring(name.length, c.length);
|
||||||
const ret = JSON.parse(str);
|
return parser ? parser.parse(JSON.parse(str)) : str;
|
||||||
return parser ? parser.parse(ret) : ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user