Next.js Fullstack Building Process
Unanswered
Pteromalid wasp posted this in #help-forum
Pteromalid waspOP
Hello there,
I'm currently developing an Application using Next.js for Frontend and Backend as a single project additional to using Prisma as ORM for my PostgreSQL DB. The App uses SSR, CSR as well as SSG.
Problem is: when building the application, the process is corrupted by referring to data on an endpoint that is currently not avaiable.
Is there a way to priotise the building process of the backend, so that when building the frontend the fetch calls are working correctly?
Fetch Example in Frontend:
async function fetchOrganizations(): Promise<Organization[]> {
try {
const res = await fetch(
next: { revalidate: 3600 },
});
.......
}
I'm currently developing an Application using Next.js for Frontend and Backend as a single project additional to using Prisma as ORM for my PostgreSQL DB. The App uses SSR, CSR as well as SSG.
Problem is: when building the application, the process is corrupted by referring to data on an endpoint that is currently not avaiable.
Is there a way to priotise the building process of the backend, so that when building the frontend the fetch calls are working correctly?
Fetch Example in Frontend:
async function fetchOrganizations(): Promise<Organization[]> {
try {
const res = await fetch(
${process.env.NEXT_PUBLIC_BACKEND_ROOT}organization, {next: { revalidate: 3600 },
});
.......
}
5 Replies
American black bear
Your app should not depend on backend at build time.
Pteromalid waspOP
That's right. Question is: how to without splitting frontend and backend into different applications?
American black bear
You can make the route which is causing the problem at build time dynamic
try adding this to your route:
export const dynamic = "force-dynamic"
export default function DynamicPage() {
const data = fetch(...)
}