nuxt-modules / nuxt-modules/sanity
Set privateRuntimeConfig for cdn use
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 265
- Forks
- 43
- Avg merge
- 11h
- Merged PRs (30d)
- 18
Description
When using Nuxt in SPR mode, like …
export default {
ssr: true,
target: 'static',
…
}
(in nuxt.config.js)
… and using Sanity with useCdn: true, content is not immediately updated, when running/triggering nuxt generate/npm run generate.
Fyi: At the Sanity dashboard you can configure web hooks, that are triggered when content changes. So usually you would trigger nuxt generate at this place.
The problem is: When using useCdn: true, we’ll get a cached response, that is not up to date. This is why we need to achieve useCdn being set to false while generating.
Overriding useCdn inside privateRuntimeConfig will solve the problem.
sanity: {
projectId: process.env.SANITY_PROJECT_ID,
dataset: 'production',
useCdn: true,
},
privateRuntimeConfig: {
sanity: {
useCdn: false,
},
},
(in nuxt.config.js)
So I was wondering why this isn’t the default behaviour?
Or at least add this to the docs?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Nuxt configuration shown in nuxt.config.js and trace how privateRuntimeConfig is applied during nuxt generate or npm run generate. Check how the Sanity useCdn setting is resolved for static generation, then verify that generation uses useCdn: false while normal runtime use remains unchanged; if that is not appropriate, document the required configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxtjs, typescript
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100