Repeated POST Requests When Opening a Chat in my Next.js application
Unanswered
American black bear posted this in #help-forum
American black bearOP
I have a simple conversations app built with Next.js, Supabase, and deployed on Vercel. When I open a chat to load messages and other relevant info, I’m seeing multiple POST requests firing off in my network tab—even though only the first few requests actually fetch the needed data. I’ve double-checked my code to ensure I’m not calling the data-fetching function more than once, but the extra requests persist. This severely slows down the speed of the application, especially when opening and loading a chat.
I’m looking for guidance on what might cause these repeated calls and how to identify and stop them. Any advice would be greatly appreciated!
I’m looking for guidance on what might cause these repeated calls and how to identify and stop them. Any advice would be greatly appreciated!
2 Replies
Are you using Server Actions to fetch data? Because that's not recommended by Next.js.
Also if this component is a client component and it re-renders n times it might be calling the same function n times.
Also if this component is a client component and it re-renders n times it might be calling the same function n times.
I’m seeing multiple POST requests firing off in my network tab—even though only the first few requests actually fetch the needed dataHow are you making sure of this?