What does cake have to do with content operations? šŸ° šŸ‘€ Find out in our Spring Release... →

User encounters empty result due to Incognito mode in Sanity query

4 replies
Last updated: Mar 18, 2025
Hi Sanity Supports. I have an app that makes a v1 query withCredential set to true. I can see from the devTools that the sanitySession cookie was included with the request. The user that is logged in is with Contributor role. However I got a response with empty result. while if I ran the same query in Vision, I got a result.
// response
{
    "query": "*[\n    _type == \"post\"\n    \u0026\u0026 slug.current == $slug\n    \u0026\u0026 _id in path(\"drafts.**\")\n  ] | order(_updatedAt desc)[0] {\n  _id,\n  title,\n  slug,\n  body,\n  authors[]-\u003e    \n}",
    "result": {},
    "ms": 2
}

// payload
query: *[
    _type == "post"
    && slug.current == $slug
    && _id in path("drafts.**")
  ] | order(_updatedAt desc)[0] {
  _id,
  title,
  slug,
  body,
  authors[]->    
}
$slug: "here-s-a-2nd-draft"
Mar 18, 2025, 12:20 AM
Oh never mind, I was running in Incognito mode. :p
Mar 18, 2025, 12:33 AM
should I just delete this thread?
Mar 18, 2025, 12:40 AM
No, you can keep it in case some one else runs into the same issue šŸ˜„
Mar 18, 2025, 4:32 AM
hi
user J
, this same exact request when ran in Safari. It never included a request cookie, so it always returned empty results. Here's the server response header:
:status: 200
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: <http://localhost:3000>
Access-Control-Expose-Headers: Content-Type, Content-Length, ETag, X-Sanity-Deprecated, X-Sanity-Warning, X-Sanity-Shard
Access-Control-Max-Age: 600
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Content-Encoding: gzip
Content-Length: 193
Content-Type: application/json; charset=utf-8
Date: Tue, 18 Mar 2025 16:12:40 GMT
ratelimit-limit: 500
ratelimit-remaining: 499
ratelimit-reset: 1
sanity-gateway: k8s-gcp-us-w1-prod-ing-01
sanity-query-hash: XP0VgQc4D5U c51eYPQvYkc
Server-Timing: api;dur=7
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Vary: Accept-Encoding, origin
Via: 1.1 google
x-ratelimit-limit-second: 500
x-ratelimit-remaining-second: 499
x-sanity-shard: gcp-eu-w1-prod-40009
x-served-by: gradient-query-5fcf9b7b9f-rxs4z
do you know if we need to do some extra for Safari to honor withCredentials:true?
Mar 18, 2025, 4:21 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?