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.

Issues with `/api/pages` and Sitemap on Payload Cloud

default discord avatar
notchr2 years ago
21

This is odd



What's the request look like



?

  • default discord avatar
    bruvimtired2 years ago

    I've figured figured it to be something wrong with my lexical editor content in the

    /

    route but cannot figure out what it is. All my other routes load fine, only when trying to load

    /api/pages

    and

    /

    I get the error above

  • default discord avatar
    notchr2 years ago

    Payload v2?

  • default discord avatar
    bruvimtired2 years ago
    const pages: Page[] = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/api/pages`, {
            next: { revalidate: 300 },
        })
            .then(async (res) => {
                return await res.json();
            })
            .then((res) => {
                return res.docs;
            });


    Yep



    It was working before then my client told me about a slowdown on the site and I realised it was failing requests

  • default discord avatar
    notchr2 years ago
    const pages: Page[] = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/api/pages`, {
            next: { revalidate: 300 },
        })
    const res = await res.json();
     const docs = res.docs


    just a lil cleanup



    hmmm

  • default discord avatar
    bruvimtired2 years ago

    Ah ok

  • default discord avatar
    notchr2 years ago

    Do you have access control on the pages?

  • default discord avatar
    bruvimtired2 years ago

    funny thing is, it works fine locally, I set my db to be my payloadcloud db on my local instance and it works fine, no slow downs



    Nope, none



    Well - it is allowed to read

  • default discord avatar
    notchr2 years ago

    Can you check the requests in the network tab



    and tell me the status

  • default discord avatar
    bruvimtired2 years ago

    From which page?



    Website is not loading at all now 😣

  • default discord avatar
    notchr2 years ago

    So



    Whenever you get to a page, and it's broken, or you dont get data



    Open your developer tools and check inspector



    And click network, based on the failure status of the request, you can infer some things

  • default discord avatar
    bruvimtired2 years ago

    This is the current state of it, but wasnt like this a week ago



    images were loading fine

  • default discord avatar
    notchr2 years ago

    No issues there



    How about your console errors



    ?

  • default discord avatar
    bruvimtired2 years ago

    Hotjar, GTM and maps errors cos I have an adblocker

  • default discord avatar
    notchr2 years ago

    Oh im sorry, i mean your payload admin panel

  • default discord avatar
    bruvimtired2 years ago

    Ohh

  • default discord avatar
    notchr2 years ago

    Basically, anywhere you notice an error



    Lets try and check what happened there



    Via checking the request

  • default discord avatar
    bruvimtired2 years ago

    theres a PATCH when I save which gets resolved to 200 OK and a GET request that resolves as 304 not modified

  • default discord avatar
    notchr2 years ago

    I thought you said it errors when you request /api/pages

  • default discord avatar
    bruvimtired2 years ago

    Yeah - so my home route

    /

    is causing an error where it fails to load data for

    /api/pages

    and when requesting the data for slug that matches

    /
  • default discord avatar
    notchr2 years ago

    If you go to the payload document for the page



    and click API



    what's the URL

  • default discord avatar
    bruvimtired2 years ago
    https://sniplondon.com/admin/collections/pages/65c3d63b6420cba5f33f4759/api

    It seems to have fixed itself... I am not getting errors when saving or loading the API tab



    https://sniplondon.com/api/pages

    this is also loading now



    I'm not sure what happened to the content in the lexical editor, but something mustve messed up and it seems to be fixed now



    @1049775120559898725

    I suspect it may have been caused by an image that was some how removed from the db and payload wasnt able to find it but it was referenced somehow. I reuploaded all of the images and it worked.. but not 100% sure. its confused me alot



    Just waiting for a build to complete now fingers crossed



    Its all fixed now. Thanks for the help!

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.