Nuxt/Sanity/Netlify SSR not showing up to date data issue...
I’m using Nuxt 3 with Sanity and hosted on Netlify and have always ran npm run generate to serve SSG which requires a redeploy after content/data changes. This has always generally worked fine. However recently I had to serve a build as SSR using npm run build.
So with SSR, using npm run build, if I make a change on Sanity it should be affected on the production site almost immediately, right? Each page visit should have the most up to date content (no need for a redeploy).
I have useCdn set to false in my nuxt.config.js for Sanity and I query my data using the composable useSanityQuery.
It’s bugging me out because I thought I maybe just didn’t understand SSR (as it’s my first site as SSR rather than SSG) and it can’t be Sanity as locally it’s correct and redeploying it fixes it.
Can anyone advise whether I’m completely misunderstanding SSR npm run build or should the production site be showing live changes within a reasonable timeframe? The changes never come through.
18 Replies
@rich What command do you use to deploy? Did you set up any route rules?
Thanks so much for the reply @manniL / TheAlexLichter
base is web, build command is npm run build and publish directory is web/dist
And no route rules
I also ran npm run preview locally and the Network requests are the same
If I update Sanity and test locally when using npm run preview it doesn't show the updates (same as on Netlify in prod)
Should the Network tab for SSR and SSG look similar (almost identical)? I'm comparing an SSG site I just launched with this SSR site that's having the issue and the Network tab looks very similar
What's also strange is if I exit npm run preview and update @nuxtjs/sanity to 1.8.3 (from 1.8.0) then npm run preview again... the change in Sanity still isn't there. I'd have assumed on npm run preview it would've shown me the most up to date data...
Almost like a redeploy...
no problem!
I am not very experienced with the sanity module to be fair
but: Did you provide a token?
otherwise, useCdn is set to true
This is an extract from my nuxt.config file... at the bottom I've explicity set useCdn to false...
Two things:
You should set the "env"-based things via runtimeConfig as described here
https://sanity.nuxtjs.org/getting-started/configuration#runtime-configuration
(Also take care of how you name the runtimeConfig things - see https://www.youtube.com/watch?v=_FYV5WfiWvs)
and you need a token (
token: process.env.NUXT_SANITY_TOKEN,
), otherwise useCDN
will be set to trueSo I should be generating an API token in Sanity and using that even if I explicity set useCdn to false? Weird!
So I should be generating an API token in Sanity and using that even if I explicity set useCdn to false? Weird!Because I assume you can't use the non-CDN version without a token, but as mentioned, I don't know much about sentry 😋
What's even weirder is that Vue Telescope states the Deployment is 'Static'
do you have a link to your app?
https://www.gouxstudio.com – thanks so much for looking
Goux Studio New York makes contemporary furniture and objects. The Plus Collection is a family of everyday items all designed around the same plus-shaped extrusion, including wall-mounted nightstands, mirrors, planters, shelves, and hooks—practical and versatile pieces that display an understated and timeless character.
yup
seems like the deployment is static indeed

which must be the main issue
make sure your build command is not running
nuxt generate
but nuxt build
(though netlify should auto-detect that)
I'm so confused 😩
It's the same if I do npm run build locally then use node .output/server/index.mjs
I'm guessing window.NUXT.prerenderedAt on a SSR site should be the time you visited the page?
Or I guess serverRendered would be true
Okay I figured this out... I had this in my nuxt.config.js for the sitemap.xml which was prerendering everything... commented this out and it now works as expected
So now I need to work out how to have a sitemap on SSR haha
@rich disable crawlLinks
and you can even remove the routes there, then the sitemap will be updated "on the go"
Thanks for all the help @manniL / TheAlexLichter