You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

访问Next.js的/admin页面时出现SyntaxError: Unexpected token u in JSON求助

Next.js + Sanity.io Admin页面JSON解析错误排查

访问http://localhost:3000/admin时出现以下错误:

error - SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()

我正在用Next.js和Sanity.io开发Web应用,目前进度到教程的1:07:02处。

相关代码

主网站目录中Admin页面路由代码

'use client';
import config from '@/sanity.config';
import { NextStudio } from 'next-sanity/studio';

export default function Adminpage() {
    return <NextStudio config={config} />;
}

Sanity自动生成的app.js代码

// This file is auto-generated on 'sanity dev'
// Modifications to this file is automatically discarded
import {renderStudio} from "sanity"
import studioConfig from "../../sanity.config.ts"

renderStudio(
  document.getElementById("sanity"),
  studioConfig,
  {reactStrictMode: false, basePath: "/"}
)

已尝试的解决方案

  • 检查CORS源配置
  • 验证服务器返回的JSON数据

以上方案均未解决问题,Sanity admin页面大部分为默认代码,已对比正常项目确认代码一致。

求其他可行的解决方案或排查步骤,如需其他代码片段可提供。

内容的提问来源于stack exchange,提问作者Mateo Ruiz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 19:55:01