.env在根目录中-REACT_APP_SANITY_PROJECT_ID= //project id REACT_APP_SANITY_TOKEN= //project token
src-中的client.js
import sanityClient from "@sanity/client";
import imageUrlBuilder from "@sanity/image-url";
export const client = sanityClient({
projectId: process.env.REACT_APP_SANITY_PROJECT_ID,
dataset: "production",
apiVersion: "2023-01-01",
useCdn: true,
token: process.env.REACT_APP_SANITY_TOKEN,
});
const builder = imageUrlBuilder(client);
export const urlFor = (source) = builder.image(source);
about.jsx-我试图从健全中获取有关数据
尝试在/src目录中添加.env文件