✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Troubleshooting a 404 error in Sanity/Remix tutorial

7 replies
Last updated: Dec 21, 2021
I'm running through
user T
Sanity/Remix tutorial (https://www.sanity.io/guides/remix-run-live-preview ) but have run into an error that I cannot figure out. It says,
Error: HTTP 404 Not Found: <https://undefined.api.sanity.io/v2021-03-25/data/query/production?query=*%5B_type%20%3D%3D%20%22post%22%5D%7B%20_id%2C%20title%2C%20slug%20%7D>
    at getError (/home/h/Documents/webdev/io-remix/frontend/node_modules/picosanity/lib/client.js:91:10)
    at /home/h/Documents/webdev/io-remix/frontend/node_modules/picosanity/lib/client.js:78:11
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async loader (/home/h/Documents/webdev/io-remix/frontend/build/index.js:474:17)
    at async Object.callRouteLoader (/home/h/Documents/webdev/io-remix/frontend/node_modules/@remix-run/server-runtime/data.js:73:14)

Dec 21, 2021, 2:56 PM
Looks like your project ID isn’t pulling through, take a look at:

This should have the project ID.

Can you log-out your environment variables to see if they’re being read?
Dec 21, 2021, 3:03 PM
Let me try that. Thanks.
Dec 21, 2021, 3:05 PM
Ok. I started to console.log the environment variables (although I wasn't sure where) but when I opened getClient, it was giving me the following Typescript error under config in the line
export const sanityClient = new PicoSanity(config);

Argument of type '{ apiVersion: string; dataset: string; projectID: string; useCdn: boolean; }' is not assignable to parameter of type 'ClientConfig'.
  Property 'projectId' is missing in type '{ apiVersion: string; dataset: string; projectID: string; useCdn: boolean; }' but required in type 'ClientConfig'.ts(2345)
client.d.ts(5, 3): 'projectId' is declared here.
(alias) const config: {
    apiVersion: string;
    dataset: string;
    projectID: string;
    useCdn: boolean;
import config
View Problem
No quick fixes available

Dec 21, 2021, 3:21 PM
I am only just learning TS so maybe I'll redo this without it in Remix and learn it later.
Dec 21, 2021, 3:22 PM
Ok. Its fixed. Not sure what I did wrong but I copy/pasted your config file from the repo into mine and changed ONLY the ProjectID (and commented out my entire config). The TS error disappeared from getClient and the page works. No more error. I cannot see any typos in mine (but will re-re-read to find what I did wrong).
Dec 21, 2021, 3:27 PM
AAARRRGGH! I found my error:
I wrote
instead of
in my config!
I'm horribly ashamed since I've spent 25+ years as a professional writer and copyeditor watching for those kinds of errors!
Dec 21, 2021, 3:29 PM
😂 easily done! Been there!
Dec 21, 2021, 3:54 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?