fix: Guard undefined ctx.state
This commit is contained in:
@@ -107,7 +107,7 @@ export const renderApp = async (
|
||||
};
|
||||
|
||||
export const renderShare = async (ctx: Context, next: Next) => {
|
||||
const rootShareId = ctx.state.rootShare?.id;
|
||||
const rootShareId = ctx.state?.rootShare?.id;
|
||||
const shareId = rootShareId ?? ctx.params.shareId;
|
||||
const documentSlug = ctx.params.documentSlug;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ export async function getTeamFromContext(ctx: Context) {
|
||||
} else {
|
||||
team = await Team.findOne();
|
||||
}
|
||||
} else if (ctx.state.rootShare) {
|
||||
} else if (ctx.state?.rootShare) {
|
||||
team = await Team.findByPk(ctx.state.rootShare.teamId);
|
||||
} else if (domain.custom) {
|
||||
team = await Team.findOne({ where: { domain: domain.host } });
|
||||
|
||||
Reference in New Issue
Block a user