Skip to content

v1.2.0

Choose a tag to compare

@flayks flayks released this 06 Nov 16:03
· 2 commits to main since this release

1.2.0 (2026-11-06)

Recommended: use the Sanity user token

Backends can now check the logged-in user's Sanity token, so no secret sits in the Studio bundle and access follows each user's role. Not breaking: REMOTE_FILES_SECRET keeps working, but anyone who can load the Studio can read it.

How to switch

  1. Update your backend from the new template, set SANITY_PROJECT_ID and SANITY_DATASET, then deploy. Do this first: old backends reject user tokens with 401.

  2. Update your Studio config:

     export default defineConfig({
       // ...
    +  auth: {
    +    loginMethod: 'token',
    +  },
       plugins: [
         remoteFiles({
           providers: [
             cloudflareR2Provider({
               id: 'r2',
               endpoint: process.env.SANITY_STUDIO_R2_ENDPOINT,
               publicUrl: process.env.SANITY_STUDIO_R2_PUBLIC_URL,
    -          headers: {
    -            authorization: `Bearer ${process.env.SANITY_STUDIO_R2_TOKEN}`,
    -          },
    +          sendUserToken: true,
             }),
           ],
         }),
       ],
     })
    
  3. Log in to the Studio again, then test one upload and one delete.

  4. Remove REMOTE_FILES_SECRET from the backend and Studio env.

Good to know

  • Only use sendUserToken with a backend you trust, over HTTPS: the token acts as the user on your Sanity project.
  • With a user token, deletes return 409 while a remoteFiles.file document still has that key.
  • signedUrlProvider does not support sendUserToken.

What's Changed

  • Authenticate backend requests with the Sanity user token in #5

Full Changelog: v1.1.0...v1.2.0