🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Issue accessing drafts from Astro SSR on Vercel with Sanity client token.

4 replies
Last updated: Apr 4, 2024
I’m trying to access drafts from Astro SSR on Vercel, I created a client with client with a token
const sanityAuthClient = sanityClient.withConfig(
  { 
    token: import.meta.env.SANITY_API_TOKEN, 
    useCdn: false
  }
);
with
Contributor permissions. Looks like that’s not enough. If I click on my preview link from studio in dev mode it actually loads fine.
Apr 3, 2024, 8:35 AM
Something sounds off here. In our docs we define that role as:> • Contributor: Read and write access to draft content within all datasets, with no access to project settings.
So I’d assume it would work.

Are you saying that same set up works locally, though? If that’s the case then I’d double check that your deployed version has access to your var.
Apr 3, 2024, 5:28 PM
Working now. Sorry I was assuming that when I ran
sanity deploy
the project was built before being deployed.
Apr 4, 2024, 9:18 AM
which actually shouldn’t have made a difference, anyway ya i think it was something about access to the env var.
Apr 4, 2024, 9:20 AM
Great!
Apr 4, 2024, 4:41 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?