Next.js Discord

Discord Forum

Route-handler question

Unanswered
Gharial posted this in #help-forum
Open in Discord
GharialOP
Hi, I'm using the NextJS for a green-field frontend project. I love the framework but am running into the following problem.

As part of the architecture, we'd like to use the frontend server as a proxy for all external requests. We want to route any calls to /api to
an open flask server running on the same EC2 instance as our frontend server. However, sometimes my post request would go through but then the
exact same request would give the following error RequestContentLengthMismatchError . I ended up using node-fetch instead of the native
fetch in the NextJS server but am wondering if this is an issue others have encountered before?

Taking a step back am I following best practices? Thanks!

3 Replies

GharialOP
Also just as a note, rewrites did not work because the redirect request is sent relative to the CLIENT browser, whereas I want the rewrite to be relative to the Next server. I could have misimplemented this however.
GharialOP
Yea actually this was the article that made me use node-fetch to resolve my issues.