Skip to main content

Posts

Showing posts with the label sanity

Setup sanity client in react

  Step 2. Crate a file with name sanity.js at root level of project. In side sanity.js write this code. import sanityClient from "@sanity/client" ; import { ImageUrlBuilder } from "@sanity/image-url" ; const client = sanityClient ({     projectId : 'qwoxusny' ,     dataset : 'production' ,     // to optimise cache if things not work     useCdn : true ,     apiVersion : "2021-10-21" , }); // now im going to make image url builder this will pull image urls // when i'm going to chnage/update image it provide the new url of // that image. const builder = imageUrlBuilder ( client ); export const urlFor = ( source ) => builder . image ( source ); export default client ; Step 3 . Add cors origin in sanity to white list hostnames. //  RUN this to add exception for localhost 300 CORS policy //  sanity cors add http://localhost:3000 /*     what is ther purpose od cross-origin: when we want to fetch ...