
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeLooking at your error, the issue is clear: https://undefined.api.sanity.io/... shows that your projectId is undefined, which means your environment variables aren't being loaded properly by Remix.
Your Sanity client can't find the project ID, so it's trying to connect to undefined.api.sanity.io instead of something like 79w8op0f.api.sanity.io. This causes the 404 error.
1. Check your .env file exists and has the correct values
The tutorial you're following creates a .env file in your Remix project root (/remix-live-preview/.env). Make sure it contains your actual project ID, not the example one:
# .env - Replace with YOUR project ID
SANITY_STUDIO_PROJECT_ID="your-actual-project-id"
SANITY_STUDIO_DATASET="production"
SANITY_STUDIO_URL="http://localhost:3333"
SANITY_STUDIO_STEGA_ENABLED="true"2. Find your actual Project ID
You can find it in your Sanity Studio directory:
/sanity-live-preview/sanity.config.ts and look for the projectId valueIt should look like "79w8op0f" (8 random characters).
3. Restart your Remix dev server
This is critical! Environment variables only load when the server starts:
# Stop your server (Ctrl+C), then restart:
npm run dev4. Verify the fix
Add this temporarily to your route to confirm it's working:
export const loader = async () => {
console.log('Project ID:', process.env.SANITY_STUDIO_PROJECT_ID)
// ... rest of your loader code
}Check your terminal - it should print your actual project ID, not undefined.
If you're still seeing undefined:
.env file is at the root of your Remix project (same folder as package.json)@sanity/client package (not picosanity which your error mentions - the tutorial uses the newer client)Once your project ID is correctly loaded, the 404 error will disappear and you'll be able to query your Sanity content!
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store