sanity icon indicating copy to clipboard operation
sanity copied to clipboard

feat: support proxying useSanityQuery requests

Open rdunk opened this issue 5 months ago โ€ข 2 comments

๐Ÿ”— Linked issue

N/A

โ“ Type of change

  • [x] ๐Ÿ“– Documentation (updates to the documentation or readme)
  • [ ] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [ ] ๐Ÿ‘Œ Enhancement (improving an existing functionality)
  • [x] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

Introduces support for proxying requests made using useSanityQuery, this will allow apps that need to query private datasets to do so without having to use server components, and they can largely follow the same patterns as those used by apps that query public datasets.

It will be up to the user to implement their own server handler for proxying requests. However this PR also ships a useful helper (validateSanityQuery, see example in playground app) which makes this quite simple and means one handler can be used for all (most?) queries, rather than needing to create server handlers for each unique GROQ query users want to execute. The module now statically analyses all GROQ queries in the app at build time, so the helper can validate incoming queries against a whitelist to prevent use of this endpoint for other queries.

rdunk avatar Aug 14 '25 20:08 rdunk

Deploy Preview for nuxt-sanity-module ready!

Name Link
Latest commit 85c34a2b2e17ece33b419c09d01094a59992b2d7
Latest deploy log https://app.netlify.com/projects/nuxt-sanity-module/deploys/68c9486efe8a6b00085fb119
Deploy Preview https://deploy-preview-1286--nuxt-sanity-module.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Aug 14 '25 20:08 netlify[bot]

Open in StackBlitz

npm i https://pkg.pr.new/@nuxtjs/sanity@1286

commit: 85c34a2

pkg-pr-new[bot] avatar Aug 18 '25 12:08 pkg-pr-new[bot]