Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Payload seems to refuse to serve response to a request during revalidation of Next.js app

default discord avatar
martafiixek2 years ago
1

Hi,



I have a monorepo setup with Payload and Next.js.



I use a

pages

router in Next.js, and I use on demand static revalidation. The static revalidation works, until to a point, where it seems Payload refuses to serve a meaningful JSON response to my Next.js application during the revalidation phase (therefore the revalidation crashes).



When I change content in Payload CMS, and I save it once, the revalidation works. If I save it twice, three four times it still works.



However, when I want to save the content on like a 10th try or a certain amount of seconds after the first save, revalidation error is thrown as the fetch from Next.js to Payload CMS doesn't return a JSON content as it should.



Ok, it seems like I solved it. Both Payload CMS and Next.js are behind a Traefik (half proxy). I thought it can be a rate limiting problem and it was! In according to Payload documentation I implemented this into configuration and now every request to Payload during revalidation returns an OK JSON response. Now even a huge amount of revalidation requests (1 revalidation every second) finish correctly.



rateLimit: {
    trustProxy: true,
    max: 5000,
  },
    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.