Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 部署NextJs时Vercel中发生生成错误:无效的JSON令牌_Reactjs_Api_Fetch_Next.js_Vercel - Fatal编程技术网

Reactjs 部署NextJs时Vercel中发生生成错误:无效的JSON令牌

Reactjs 部署NextJs时Vercel中发生生成错误:无效的JSON令牌,reactjs,api,fetch,next.js,vercel,Reactjs,Api,Fetch,Next.js,Vercel,实际上,在我的笔记本电脑上,它使用npm-run-dev运行得很好&在执行npm-run-build时,它也可以正常运行,没有任何错误。 当我把它部署到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://b

实际上,在我的笔记本电脑上,它使用npm-run-dev运行得很好&在执行npm-run-build时,它也可以正常运行,没有任何错误。

当我把它部署到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
13:21:05.897信息-正在收集页面数据。。。
13:21:06.193>发生生成错误
13:21:06.195 FetchError:位于的json响应正文无效https://bcanepaltu.com/wp-json/wp/v2/posts?per_page=200 原因:JSON中位置0处出现意外标记<
13:21:06.195 at/vercel/path0/node_modules/node fetch/lib/index.js:272:32
13:21:06.196在处理和拒绝时(内部/处理/任务队列.js:93:5)
13:21:06.196异步getStaticPath(/vercel/path0/.next/server/pages/posts/[id].js:39:16)
13:21:06.196异步buildstaticpath(/vercel/path0/node_modules/next/dist/build/utils.js:16:80)
13:21:06.196异步/vercel/path0/node_modules/next/dist/build/utils.js:26:622
13:21:06.196异步Span.traceAsyncFn(/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584){
13:21:06.196类型:“无效json”
13:21:06.196    }
13:21:06.227错误命令失败,退出代码为1。
13:21:06.227信息访问https://yarnpkg.com/en/docs/cli/run 有关此命令的文档。
13:21:06.247错误:命令“纱线运行构建”已退出,返回1
因此,我试图获取我的WordPress站点的JSON并生成帖子 在dev上运行良好,并且在这个URL上看到
那个么为什么它给出了无效JSON令牌的错误呢?

我也有同样的问题。实际上已经解决了。。。通过禁用Cloudflare上的防火墙。。。Cloudflare机器人保护和防火墙保护阻止了它。。。通过禁用cloudflare的机器人战斗模式和防火墙修复。