Initiating another prisma client for SSR
I closed my project, opened it up again and got an error on prisma.etc. On my page that does SSR.
I have since added the prisma client on that page. Initiated it, now it's working. Then i deleted it, shut down my project and spun it up again and it's working fine. What is this magic?
/code
xport async function getStaticProps(
context: GetStaticPropsContext<{ slug: string[] }>
) {
// const prisma = new PrismaClient();
const helpers = createServerSideHelpers({
router: appRouter,
ctx: { prisma },
transformer: superjson,
});
const slug = context.params?.slug; // Access the first element of the slug array
await helpers.post.getPost.prefetch({ slug });
return {
props: {
trpcState: helpers.dehydrate(),
slug,
},
revalidate: 1,
};
}
export const getStaticPaths: GetStaticPaths = async () => {
const pathsData = [];
return {
paths: pathsData,
fallback: 'blocking',
};
};
0 Replies