feat: support proxying useSanityQuery requests
๐ 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.
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...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.