vercel / platforms

A full-stack Next.js app with multi-tenancy and custom domain support. Built with Next.js App Router and the Vercel Domains API.
https://app.vercel.pub
5.38k stars 688 forks source link

Post view page generates infinite network requests #365

Open itaykat opened 7 months ago

itaykat commented 7 months ago

When entering a specific post, the page generates non stop POST requests to thttps://app.domain.com/post/

jocadevone commented 5 months ago

I solved it by adding an empty array as a dependency in the useeffect in the nav.tsx component. I'm not sure it's the right thing to do, but it works. Screenshot 2024-01-05 at 7 46 19 p m

JoeCam88 commented 5 months ago

I had the same problem, but when I remove the dependency array then the navigation will not work correctly and the "Back to all posts" menu will take back to the all sites page. My solution for the issue to add the siteId to the dependency list in the nav.tsx, so finally it looks like this.

useEffect(() => {
    if (segments[0] === "post" && id && !siteId) {
      getSiteFromPostId(id).then((id) => {
        setSiteId(id);
      });
    }
  }, [segments, id, siteId]);