Next.js Discord

Discord Forum

`rewrites` doesn't proxy the fetch request on server side

Unanswered
Karelian Bear Dog posted this in #help-forum
Open in Discord
Karelian Bear DogOP
I just opened an issue:
- https://github.com/vercel/next.js/issues/61984

I'm using backend server on same origin with /api routes.
So I don't use route handlers of nextjs server, instead I need to rewrites /api to my backends.
like this:

const nextConfig = {
  async rewrites() {
    return [{ source: '/api/:path*/', destination: 'http://localhost:8080/api/:path*/' }];
  },
};


This works well when the fetches are fired on the browser.
But when fired on the nextjs server side like in server action, it doesn't work !!

Is there any issues or discussions opened already about this?

Please help 🥲🙏🏻

0 Replies