Next.js Discord

Discord Forum

API requests being sent twice from Next.js to Laravel backend

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Hey everyone, I’ve got a Next.js frontend with a Laravel backend. For some reason, every API call (like /api/user) is hitting my Laravel backend twice. I checked the Laravel logs and can confirm the same endpoint is requested two times each time I visit a page.

I already tried disabling React’s strict mode in next.config.js and rebuilt the project, but it’s still happening. Any idea what could be causing this double request behavior?

Im testing locally on Kali Linux (localhost), but wondering if it might fix itself after deploying to a VPS.

2 Replies

If it’s on prod then it wont change after deployment.


The problem is most likely is caused by a state change and rerender.

If you are using useeffect send the code here so we can take a closer look

If not then send the code for the component that renders and sends the request and the parent component as well
alirght