GetStaticProps Revalidate 没有按预期工作

问题描述 投票:0回答:1

问题: 当我使用来自 next-i18next 的 (serverSideTranslations) 时,重新验证不起作用。请在下面查看我的代码。

当新用户注册时,会为每种语言生成一个静态页面:(da (Default), en, sv, de). 对于在构建时(部署在 Vercel 上时)所有已生成的页面,Everyting 可以与下面的代码一起正常工作。

当新用户注册时,页面不会重新验证并抛出 500 内部服务器错误。 / 页面没有生成

请参阅代码中的注释!

export async function getStaticPaths({ locales }) {
  const { data: profiles, error } = await supabase.from("profiles").select("*");
  console.log(locales);

  const paths = profiles
    .map((profile) =>
      locales.map((locale) => ({
        params: { profileName: profile.username },
        locale, // Pass locale here
      }))
    )
    .flat();

  console.log(paths);
  return { paths, fallback: "blocking" };
}

export async function getStaticProps({ params, locale }) {
  const { data: profiles, error } = await supabase
    .from("profiles")
    .select("*")
    .eq("username", params.profileName)
    .single();

  return {
    props: {
      profiles,
      ...(await serverSideTranslations(locale, ["Profil"])), //When this line is removed everything works fine  --- When its added GetStaticPaths and GetStaticProps breaks.
    },
    revalidate: 30,
  };
}

javascript next.js i18next supabase
1个回答
0
投票

你能找到问题吗? 我们面临着类似的问题。

调用 Supabase 时第一次渲染出现随机错误 500。

第二次调用 supabase 时 getStaticPaths 没有错误。

另外,有时似乎有值时返回和空值。

© www.soinside.com 2019 - 2024. All rights reserved.