reddie
reddie
TTCTheo's Typesafe Cult
Created by reddie on 11/15/2024 in #questions
Running getServerSideProps auth checks from external function call
really? was not aware of that, mb mb.. i thought it was vercel-specific
15 replies
TTCTheo's Typesafe Cult
Created by reddie on 11/15/2024 in #questions
Running getServerSideProps auth checks from external function call
Unfortunately, I am self-hosting this app via docker, so edge is not available
15 replies
TTCTheo's Typesafe Cult
Created by reddie on 11/15/2024 in #questions
Running getServerSideProps auth checks from external function call
I am currently using this approach, i think it's a good way around it?
not sure how to properly type it though, the below works though
// ~/server/helpers/auth-helper.ts
import { type GetServerSidePropsResult } from "next";

export const returnToHome = {
redirect: {
destination: "/",
permanent: false,
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as GetServerSidePropsResult<Record<string, any>>;
// ~/server/helpers/auth-helper.ts
import { type GetServerSidePropsResult } from "next";

export const returnToHome = {
redirect: {
destination: "/",
permanent: false,
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as GetServerSidePropsResult<Record<string, any>>;
// ~/pages/page.tsx
if (authCheck) {
return returnToHome;
}
// ~/pages/page.tsx
if (authCheck) {
return returnToHome;
}
15 replies