Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Sanity client misconfigured in Next.js? apiVersion, useCdn and perspective fixes

If you inherited a Next.js site and the Sanity content is stale, leaking drafts, or oddly expensive to fetch, look at the Sanity client configuration before you touch anything else. Three settings, apiVersion, useCdn and perspective, cause a surprising share of the problems I see on inherited projects. They sit in one small file that nobody has opened since the first commit. Symptoms of a…

Sanity client misconfiguration is a common issue in Next.js projects, leading to stale content, duplicate entries, high API request counts, and inconsistent queries. The three main settings that cause problems are apiVersion, useCdn, and perspective. These settings are usually hardcoded in a small configuration file that nobody opens after the initial commit.

The most frequent issue is an outdated or missing apiVersion, which causes the query API to use old behaviour. Fixing this requires setting a fixed date string for the version, rather than relying on the current date.

Another common problem is incorrectly configuring useCdn. If set to false, every page build and cache miss will hit the live API, increasing latency and request counts. On the other hand, if set to true in draft or write-then-read code, the CDN may serve slightly older responses, causing stale previews and server actions.

The wrong perspective setting can also lead to issues. Using the wrong perspective (published, drafts, or raw) can result in unpublished content appearing on the live site, each document appearing twice, or the preview mode not working as expected.

Lastly, a single client trying to serve multiple roles (public pages, draft previews, and server-side writes) can cause problems. It is cleaner to have two clients with explicit settings for each role. By doing this, you can ensure that public pages only use the CDN and see published content, while draft mode fetches fresh reads and drafts layered over published content.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

I wrote a script to stop my internal links from rotting

A site with 286 pages has a link problem. Every new page is an orphan until something points at it, and every redesigned URL silently breaks old links. I stopped doing this by hand a while ago.

  • Script scans and categorizes pages by topic
  • Inserts related-reading links during build process
  • Verification step ensures all links are valid

Super Script Runner v1.1.2 — Clean, Ad-Free Userscript Manager (Native MV3)

Hey everyone! Quick update on Super Script Runner — a lightweight, ad-free userscript manager I built as a clean alternative to bloated tools like Ace Script.

  • Super Script Runner v1.1.2 released with ad-free, lightweight userscript manager
  • Chrome's native userScripts API enhances performance and security
  • Version 1.1.2 maintains essential features while removing background updates

WhatsApp Under Attack? CERT-In Flags High-Risk Flaws — Update Now

WhatsApp Under Attack? CERT-In Flags High-Risk Flaws — Update Now WhatsApp is the app nobody thinks about until it breaks.

  • Five high-risk vulnerabilities found in WhatsApp and WhatsApp Business
  • Flaws could enable attackers to execute code, steal data, bypass security
  • Meta released patches after discovery by external researchers and Bug Bounty

Tech job market this week: salaries and hiring in 4 markets (2026-W48)

Every week we collect fresh job ads from five tech job markets and publish the numbers: how many jobs, how many show a salary, what they pay and who is hiring.

  • In the US market, 335 tech jobs were listed with 33% offering salary info, median salary $125k.
  • Remote startup jobs in the US had a higher median salary of $175k compared to 335 US jobs.
  • In France, 723 tech jobs with salary info had a median yearly salary of €45k.

More from Sunday, 29 November 2026 →