Hi guys,
I'm using NextJS 14.0.4.
I'm trying to fetch data from the local api to init a few things for components.
Actually everything works fine in development, but it fails during the build, because the server is obviously not running on port 3000 while building.
I'm kinda lost, do I need to turn my component into client ones?
In this case, I can't do a async call.
Here is the content of the component :
const res = await fetch(Config.API_ENDPOINT_URL + '/gameserver', {
next: { revalidate: 10 },
});
const gameserver: GameServer = res.ok ? await res.json() : undefined;
return (
<html lang="en">
<body className={inter.className}>
<div className="flex flex-col h-screen justify-between">
<Navbar gameserver={ gameserver } />
<Home />
<Footer discordLink={Config.DISCORD_LINK}/>
</div>
</body>
</html>
);
The /api/gameserver also makes an external fetch.
The Config.API_ENDPOINT_URL is initialized with process.env using Zod for validation.
So in development, API_ENDPOINT_URL=http://localhost:3000.
I'm new to NextJS, I may have missed something.
Any help appreciated.
Thanks
