Why i have this error on my vps ?
Unanswered
Barbary Lion posted this in #help-forum
Barbary LionOP
Localy build works fine but on my vps o had this error
17 Replies
Barbary LionOP
I propably should use a docker 😄
Are you using route handler?
Barbary LionOP
app router
App router has route handler
The api routes you make
Barbary LionOP
yup i use it
Long story short, one of your fetch requests is failing, which ends up returning a html page instead of a json object(which you expect).
Always use res.ok before res.json()
Always use res.ok before res.json()
Barbary LionOP
build on local machine
You are static exporting, which means the data will be pre-fetched at build time and not be fetched on runtime.
@Barbary Lion build on local machine
Is your nextjs server running in the background?
@Clown Long story short, one of your fetch requests is failing, which ends up returning a html page instead of a json object(which you expect).
Always use res.ok before res.json()
Barbary LionOP
export async function GET() {
const administrators = await AdministratorDb.findAll();
return NextResponse.json(administrators);
}how to use here res.ok ??
Where you are using this api route
What's happening is, its trying to pre-fetch the data to bake it into your code (cause its a static export),but your api is built on nextjs server, which isnt running at build-time so you get that error.
@Clown Where you are using this api route
Barbary LionOP
const AdministratorsManagePage = async () => {
const administrators = await apiCall<AdministratorListResponse>(
ApiRoute.BASE_ADMINISTRATORS,
{
next: { tags: [RevalidateTag.ADMINISTRATORS] },
},
);
return (
<AdminPageWrapper
headerData={{
title: "ZarzÄ…dzaj Administratorami",
}}
>
<AdministratorsTable data={administrators} />
<AddAdministratorDialog />
</AdminPageWrapper>
);
};
export default AdministratorsManagePage;I don't know how to prevent this
const administrators = await apiCall<AdministratorListResponse>(
ApiRoute.BASE_ADMINISTRATORS,
{
next: { tags: [RevalidateTag.ADMINISTRATORS] },
},
);should i use db call here? instead request ?