实际上在我的笔记本电脑上,它使用 npm run dev 运行良好,并且在执行 npm run build 时它也可以正常工作,没有任何错误。 Build Success Image
当将它部署到 vercel 时,我收到错误
13:21:05.897 info - Collecting page data...
13:21:06.193 > Build error occurred
13:21:06.195 FetchError: invalid json response body at https://bcanepaltu.com/wp-json/wp/v2/posts?per_page=200 reason: Unexpected token < in JSON at position 0
13:21:06.195 at /vercel/path0/node_modules/node-fetch/lib/index.js:272:32
13:21:06.196 at processTicksAndRejections (internal/process/task_queues.js:93:5)
13:21:06.196 at async getStaticPaths (/vercel/path0/.next/server/pages/posts/[id].js:39:16)
13:21:06.196 at async buildStaticPaths (/vercel/path0/node_modules/next/dist/build/utils.js:16:80)
13:21:06.196 at async /vercel/path0/node_modules/next/dist/build/utils.js:26:622
13:21:06.196 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584) {
13:21:06.196 type: 'invalid-json'
13:21:06.196 }
13:21:06.227 error Command failed with exit code 1.
13:21:06.227 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
13:21:06.247 Error: Command "yarn run build" exited with 1
所以我试图获取我的 WordPress 网站的 JSON 并生成帖子,而 https://bcanepaltu.com/wp-json/wp/v2/posts?per_page=200 在 dev 上运行良好,同时在这个 URL 上看到 那么为什么它会给出无效 JSON 令牌的错误?