Error: Configuration must contain `projectId`

Error: Configuration must contain `projectId`

我正在尝试将 sanity 后端连​​接到我的 nextjs 前端项目,虽然我的 id 和令牌在我的 client.js 文件中,但我仍然遇到这个错误:错误:配置必须包含 projectId

import sanityClient from '@sanity/client';
import imageUrlBuilder from '@sanity/image-url';
export  const client = sanityClient ({
    projectID: '****',
    dataset: 'production',
    apiVersion: '2022-03-10',
    useCdn: true,
    token: NEXT_PUBLIC_SANITY_token
});
const builder = imageUrlBuilder(client);
export const urlFor = (source) => builder.image(source);

如果有人能帮助我找到解决方案,我将不胜感激

JavaScript 是一种 case-sensitive 语言,因此在您的 Sanity client 中将 projectID 更改为 projectId(注意小写 d) .

将 projectID 键替换为 projectId。

import sanityClient from '@sanity/client';
import imageUrlBuilder from '@sanity/image-url';
export  const client = sanityClient ({
 projectId: '****',
 dataset: 'production',
 apiVersion: '2022-03-10',
 useCdn: true,
 token: NEXT_PUBLIC_SANITY_token
});
const builder = imageUrlBuilder(client);
export const urlFor = (source) => builder.image(source);