Fix 500 errors if data is invalid (#2886)

This commit is contained in:
Hariom Balhara
2022-05-26 08:38:10 +00:00
committed by GitHub
parent 7c3090bc23
commit 40c81ee405
+11 -1
View File
@@ -2294,6 +2294,12 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const session = await getSession({ req });
const typeParam = parseInt(asStringOrThrow(query.type));
if (Number.isNaN(typeParam)) {
return {
notFound: true,
};
}
if (!session?.user?.id) {
return {
redirect: {
@@ -2406,7 +2412,11 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
},
});
if (!rawEventType) throw Error("Event type not found");
if (!rawEventType) {
return {
notFound: true,
};
}
const credentials = await prisma.credential.findMany({
where: {