小编Jih*_*hoi的帖子

nextjs 13generateStaticParams 与 next/header 一起使用会导致开发模式下出现未处理的运行时错误

我正在开发一个新项目,最近在我的前端应用程序中使用了 nextjs13。

\n

当函数generateStaticParams与next/header库函数headers()一起使用时,

\n

我在开发模式下遇到错误。

\n
\n

未处理的运行时错误 - 动态服务器使用:标头

\n
\n

开发模式期间发生错误的屏幕截图

\n

但是当前端使用下一个构建/下一个启动时,不会出现错误。

\n

我使用 next/header 库的主要原因是为了获得对 cookie 的访问权限。

\n

generateStaticParamsapp/detail/[questionId]/page.tsx文件中\next/headers 在app/layout.tsx文件中

\n

应用程序/page.tsx

\n
import React from "react";\nimport QuestionCard from "../components/Card/QuestionCard";\nimport Carousel from "../components/Carousel/Carousel";\nimport HomeNavBar from "../components/HomeNavBar/HomeNavBar";\nimport { ICarousel } from "../types/carousel";\nimport TabNavigator from "../components/TabNavigator/TabNavigator";\n\nconst getGoogleSession = async () => {};\n\nconst getQuestionList = async () => {\n  const response = await fetch(`https://pioneroroom.com/questionlist`);\n  const data = await response.json();\n  return data;\n};\n\nconst page = …
Run Code Online (Sandbox Code Playgroud)

next.js next-auth react-server-components

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