Self host build error on server side rendering
Answered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
I've been trying to get my NextJS 14.2.4 application to run on self hosted environment.
Now when I started to implement pages that would load data from database, I run into error on build process, where next is trying to build pages, it fails to retrieve information from database for those pages which should load their dynamic data on page load.
Am I missing some documentation regarding server side rendering, that I should define somehow, that build would understand that data on the page is loaded on the runtime? Without changing page completely to client component?
Below is my page that throws the error.
Now when I started to implement pages that would load data from database, I run into error on build process, where next is trying to build pages, it fails to retrieve information from database for those pages which should load their dynamic data on page load.
Am I missing some documentation regarding server side rendering, that I should define somehow, that build would understand that data on the page is loaded on the runtime? Without changing page completely to client component?
Below is my page that throws the error.
import MaxWidthWrapper from "~/app/_components/max-width-wrapper";
import { getJobs } from "~/data-access/jobs";
export default async function OrdersPage() {
const jobs = await getJobs();
return (
<MaxWidthWrapper>
<h1>Jobs</h1>
<p>Below you can find your open jobs...</p>
{jobs.map((job) => {
return (
<div key={job.id}>
<h2>{job.id}</h2>
<p>{job.customerContactName}</p>
</div>
);
})}
</MaxWidthWrapper>
);
}Answered by Asiatic Lion
This seemed to be a problem while NextJS was building orders page, and didn't recognise it automatically as dynamic page, and then tried to build a static page of that during the buildtime. And during the build time I assume that docker container do not have access to surrounding environment. Got fixed by adding
export const dynamic = "force-dynamic"; to orders page, and now Next loads that page on runtime.2 Replies
Golden paper wasp
Hey there. You have localhost address as db address. Try putting your server address
Asiatic LionOP
This seemed to be a problem while NextJS was building orders page, and didn't recognise it automatically as dynamic page, and then tried to build a static page of that during the buildtime. And during the build time I assume that docker container do not have access to surrounding environment. Got fixed by adding
export const dynamic = "force-dynamic"; to orders page, and now Next loads that page on runtime.Answer