reddie
reddie
TTCTheo's Typesafe Cult
Created by reddie on 11/15/2024 in #questions
Running getServerSideProps auth checks from external function call
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const session = await getServerAuthSession(ctx);

if (!session?.user.<AUTH_CHECK>) {
return {
redirect: {
destination: "/",
permanent: false,
},
props: {},
};
}
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const session = await getServerAuthSession(ctx);

if (!session?.user.<AUTH_CHECK>) {
return {
redirect: {
destination: "/",
permanent: false,
},
props: {},
};
}
Hello there, I have frequent auth checks in my t3 (pages router), Depending on certain permissions or data, the user will be redirected to other pages. This is the case for multiple pages. I just want to clarify if offloading the processing on an external function call (to make these function calls callable in other pages more organized and reusable, as well as to declutter the long and repetitive getServerSideProps) is recommended or are there certain security risks from offloading the function calls externally? I assume the auth checks would still be done server-side (i plan on putting them somewhere like ~/server/helpers/auth.ts)
15 replies
TTCTheo's Typesafe Cult
Created by reddie on 11/2/2024 in #questions
Recommended VSCode Extensions
Hi there, Apart from the typical ones like prisma for intellisense/autocomplete if you use prisma, what extensions/profiles/configs do you use to improve your QoL when making a webapp using ct3? My primary concerns right now are: - linting/formatting - autocomplete/ intellisense - typescript qol - improving ts/nextjs dev servers Any recommendations will help!
4 replies