Using Next with an external backend
Hey Theo, I wanted to get your opinion on using next with an external api server knowing that next has its own.
In order to take advantage of next app router features do you think its nice using next server as proxy to communicate to those external api servers. And does that mean you will always have 2 round trips back and forth to fetch json data.
Im asking this because I know next is built as a full stack framework and not like some framework you would use to communicate with an external server.
Thanks for your time.
2 Replies
If I understand correctly you have a separate backed written in a different language ?
What you can do in next are rewrites you put this in your next config
Documentation https://nextjs.org/docs/pages/api-reference/next-config-js/rewrites
If I understood your problem correctly this should proxy your request correctly...
next.config.js Options: rewrites | Next.js
Add rewrites to your Next.js app.
Im not creating api routes in my next app, by proxy i meant using server actions for both queries and mutations (in client components)
Also, im just looking for personal opinions, how are people/companies are using next app router with a separate server (go, dotnet etc)