小编Ada*_*šák的帖子

Vercel 上的 Nextjs 部署 - API 请求返回 500,适用于 localhost

我将 Nextjs 应用程序部署到 Vercel,但我的 api 调用失败,响应为 500,即使它在 localhost 上运行也是如此。我可以使用 获得初始负载getStaticProps,所以我相信与数据库的连接是可以的。

我的getStaticPaths功能正常工作如下所示:

export async function getStaticProps() {
  dbConnect();
  const properties = await Property.find({
    deletedAt: { $exists: false },
    archivedAt: { $exists: false },
  })
    .sort({ refreshed: -1 })
    .limit(itemsPerPage);
  const propertiesCount = await Property.countDocuments(
    { deletedAt: { $exists: false }, archivedAt: { $exists: false } },
    { limit: 100 }
  );
  const pagesCount = Math.ceil(propertiesCount / itemsPerPage);

  return {
    props: {
      fetchedProperties: properties.map((property) => propertyToJson(property)),
      pagesCount: pagesCount, …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs next.js vercel

5
推荐指数
1
解决办法
1070
查看次数

标签 统计

javascript ×1

next.js ×1

reactjs ×1

vercel ×1