nextjs on vercel using the apis created in api folder to fetch data in server components?
Unanswered
Chausie posted this in #help-forum
ChausieOP
I want to host my next js project but not able to because i am using apis from api folder and its not available at the time of build, on local it works. Can someone point me to any article?
8 Replies
Asian black bear
ChausieOP
So, we cant do a normal hosting with own apis for testing 😦
Asian black bear
You just shouldn't fetch your own API routes in server components.
The linked page states exactly that - instead, call the code that route handler would perform in your server component.
ChausieOP
I need to present how we will fetch data in server components, i am using turborepo monorepo setup. Can i create a express server and host my apis there? Will it work? Will vercel build and host express before the frontend?
Asian black bear
There is no need for a dedicated backend unless you have good reasons for it.
ChausieOP
I need those apis, its supposed to visualise external apis in real world. I got your point of importing data directly.
ChausieOP
i am using https://jsonbin.io/. If anyone in future need any help regarding the same