Next.js Discord

Discord Forum

Page don't render because timeout

Unanswered
Eastern Carpenter bee posted this in #help-forum
Open in Discord
Eastern Carpenter beeOP
when you make a call to this url and it gives 504 (timeout), the page is not rendered.
export const getServerSideProps: GetServerSideProps = async (ctx) => {
  const { locale, req, res } = ctx;

  const token = getCookie(STORAGE_KEYS_CONSTANTS.TOKEN, { req, res });
  const isAlready2fa = getCookie(STORAGE_KEYS_CONSTANTS.ISALREADY2FA, {
    req,
    res,
  });

  if (!(token && decrypt(String(isAlready2fa)) === "true")) {
    Object.entries(STORAGE_KEYS_CONSTANTS).forEach(([_, value]) => {
      if (value !== "ISONBOARD") {
        deleteCookie(value, { req, res });
      }
    });
    return {
      redirect: {
        destination: "/",
        permanent: false,
      },
    };
  }

  const contactID = getCookie(STORAGE_KEYS_CONSTANTS.CONTATOID);
  const companyID = getCookie(STORAGE_KEYS_CONSTANTS.COMPANHIAID);
  const userData = await fetch(
    "https://meu-endpoint",
    {
      method: "GET",
      headers: {
        Origem: "meu-header-de-origem",
        "Content-Type": "application/json",
        Authorization: `Bearer ${token}`,
        contactID: `${decrypt(String(contactID))}`,
        companyID: `${decrypt(String(companyID))}`,
      },
    }
  );

  if (userData) {
    if (userData?.list?.length > 0) {
      setCookie(STORAGE_KEYS_CONSTANTS.ISONBOARD, String(true), {
        path: "/",
      });
    }
  }

  const isMakeOnboard = getCookie(STORAGE_KEYS_CONSTANTS.ISONBOARD, {
    req,
    res,
  });
  if (isMakeOnboard === "true") {
    return {
      redirect: {
        destination: "/home",
        permanent: false,
      },
    };
  }

  return {
    props: {
      ...(await serverSideTranslations(locale as string, ["common"])),
    },
  };
};


when you make a call to this url and it gives 504 (timeout), the page is not rendered.

Can anyone explain to me.

0 Replies