Next.js Discord

Discord Forum

Error when deploying my app on vercel

Unanswered
Rex posted this in #help-forum
Open in Discord
RexOP
I built an app using Next.js and Appwrite. Everything worked fine on localhost, but after deploying the app, I encountered an issue. The error occurs most often when I try to authenticate, but it also happens when I navigate to other pages afterward. The problem resolves automatically when I refresh the page, but it can happen again.

This is the full code that I get in my Vercel logs:
⨯ TypeError: Response.clone: Body has already been consumed.
    at <unknown> (/var/task/.next/server/chunks/989.js:2:6811) {
  digest: '542063668'
}

3 Replies

RexOP
fixed
Can you share what you have done to fix this and mark this response as the solution?

This can help someone in the future
RexOP
Actually, it was my mistake because I used the same function, fetchCurrentUser, in both my layout.tsx and my root page.tsx. I did this because one component in my page.tsx needs the user ID. Instead of repeating the function call, I created a UserProvider using useContext and wrapped my layout.tsx with it. Now, in my component, I can directly access the user and their ID.