简体   繁体   中英

even after apply all the rules of .env file in vite-react such REACT_APP_ , root directory, restart, process.env ,still getting process is not defined

.env in root- REACT_APP_SANITY_PROJECT_ID= //project id REACT_APP_SANITY_TOKEN= //project token

client.js in src-

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-- i was trying to fetch about data from sanity

Try adding the.env file in /src directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM