Next.js Discord

Discord Forum

Server fetch("") url is not accepting the api folder route

Answered
ekimcem posted this in #help-forum
Open in Discord
Hey all !

I am trying to send a request to next api folder in app directory.

With postman i try to send request to http://localhost:3000/api , and it wokrs.

But in server component, when i try to fetch data with fetch("/api) , it is not working and it says wonr URL.

do we need to type whole url in server components ?

6 Replies

Answer
Thank you ❤️
Can i ask one more @joulev , so what if i want to use fetch functions cache option but i will fetch data by using prisma ?
depending on how stable you feel, you can use [unstable_cache](https://nextjs.org/docs/app/building-your-application/caching#unstable_cache) which allows for caching prisma queries. but it may not be the best thing to use:
Warning: This API is being developed, and we do not recommend using it in production. It's listed here to show the future direction of the Data Cache.
Thank you so much,since its new its hard to find some answers and it is a lil bit tricky but i think that will be much better in the near future instead of client fetchings.