How to fix database conn error on build?
Unanswered
Glaucous-winged Gull posted this in #help-forum
Glaucous-winged GullOP
I'm getting the following error on my next build on my CI:
From a short google search I got that's because next tries to generate a static version of my page, and that I could fix that by doing
My
where
Can't reach database server at `127.0.0.1:5432`
From a short google search I got that's because next tries to generate a static version of my page, and that I could fix that by doing
export const dynamic = "force-dynamic";
on my page.tsx
that's causing it but that is not ideal. So instead I should use Suspense
and call the component that's causing that error inside of a Suspense
. So I tried doing that but I'm still getting the error and I really can't figure out why. My
page.tsx
looks something like:import { Suspense } from "react";
import CoursesTable from "../components/CoursesTable";
const Courses = () => {
return (
<>
<Suspense fallback={<div>Loading...</div>}>
<CoursesTable />
</Suspense>
</>
);
};
export default Courses;
where
CoursesTable
is:const CoursesTable: React.FC = async () => {
const courses = await prisma.courses.findMany({...});
return (
<div className="overflow-hidden">
... {courses.map(...)}
</div>
)
}