🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Issue with 404 error when refreshing website at /studio/desk, resolved by updating vercel.json file.

47 replies
Last updated: Dec 29, 2022
If I refresh website at /studio/desk I get a 404, but if a refresh to /studio things will reroute to /studio/desk but things work.
Can someone please explain why that might be happening?
Dec 28, 2022, 10:27 PM
could you share your sanity.config and your vercel.config, if you deployed it there?
Dec 29, 2022, 10:43 AM
Sanity Config…
{
  "root": true,
  "project": {
    "name": "Karrie's Studio",
    "basePath": "/studio"
  },
  "api": {
    "projectId": "...",
    "dataset": "production"
  },
  "plugins": [
    "@sanity/base",
    "@sanity/components",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/desk-tool",
    "asset-source-unsplash"
  ],
  "env": {
    "development": {
      "plugins": ["@sanity/vision"]
    }
  },
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema.js"
    },
    {
      "implements": "part:@sanity/base/brand-logo",
      "path": "./logo/myLogo.js"
    },
    {
      "implements": "part:@sanity/base/theme/variables/override-style",
      "path": "./styles/variables.css"
    }
  ]
}
Dec 29, 2022, 2:02 PM
I don’t know how to share the Vercel config
Dec 29, 2022, 2:03 PM
Which version of sanity are you using?
Dec 29, 2022, 2:49 PM
Regardless there should be a
vercel.config.ts
file in the root directory of the studio 🙂 (when you deploy the studio to
YOUR_DOMAIN/studio
which it appears you do)
Dec 29, 2022, 2:50 PM
Interesting
Dec 29, 2022, 2:50 PM
This is my package json file:
Dec 29, 2022, 2:51 PM
{
	"name": "mysanityproject",
	"private": true,
	"version": "1.0.0",
	"description": "",
	"main": "package.json",
	"author": "Knut Melvær <knut@sanity.io>",
	"license": "UNLICENSED",
	"keywords": [
		"sanity"
	],
	"dependencies": {
		"@sanity/base": "^2.0.5",
		"@sanity/components": "^2.0.5",
		"@sanity/core": "^2.0.5",
		"@sanity/default-layout": "^2.0.5",
		"@sanity/default-login": "^2.0.5",
		"@sanity/desk-tool": "^2.0.5",
		"@sanity/vision": "^2.0.5",
		"prop-types": "^15.6",
		"react": "^16.2",
		"react-dom": "^16.2",
		"react-hook-form": "^6.7.0",
		"sanity-plugin-asset-source-unsplash": "^0.1.3"
	}
}
Dec 29, 2022, 2:51 PM
I have another project deployed that is similar (same version and mostly same setup from what I gather), but it doesn’t have the problem of 404ing when I go to /studio/desk like this one has.
Dec 29, 2022, 2:52 PM
okay so an old version of v2, but it should work. You need to check the vercel deployment setup, seems like something is weird there 🙂 That would be my guess
Dec 29, 2022, 2:52 PM
Hmm okay
Dec 29, 2022, 2:53 PM
I was thinking to check the ENV Variables, but would you suggest what else I should look into?
Dec 29, 2022, 2:53 PM
(On Vercel)
Dec 29, 2022, 2:53 PM
I’ve made a screen recording of this issue.
Dec 29, 2022, 2:57 PM
This is on Chrome, in incognito mode.
Dec 29, 2022, 2:57 PM
So, ⬆️ above is what it looks like for the client.
I am going to share another screen recording of what it looks like for me in my chrome web browser (not in incognito mode)

My browser ⬇️ (successful attempt)
Dec 29, 2022, 3:02 PM
Seems like you aren't being logged in properly.
Dec 29, 2022, 3:38 PM
It also seems like something super specific to this website though. Other sites don’t behave like this with the need to manually remove
/desk
from the URL
Dec 29, 2022, 3:39 PM
Did you configure cors properly?
Dec 29, 2022, 3:41 PM
I was wondering about that too
Dec 29, 2022, 3:42 PM
It seems that it is setup for this site correctly
Dec 29, 2022, 3:43 PM
I may just try to upgrade sanity and see if that will have any positive effect
Dec 29, 2022, 3:44 PM
Just for kicks remove the https and replace with http in the cors setup.
Dec 29, 2022, 3:48 PM
Yea I got this error (Even if I try to access http):
Dec 29, 2022, 3:51 PM
Ah well that isn't it lol.
Dec 29, 2022, 3:52 PM
Have you tried it in another browser?
Dec 29, 2022, 3:52 PM
Yea - With Safari it just doesn’t work. Same problem with Firefox
Dec 29, 2022, 3:54 PM
Ok yea get the simple things out of the way first. Hmmmm
Dec 29, 2022, 3:54 PM
https://www.sanity.io/docs/example-migrating-the-blog-template-from-studio-v2-to-v3
Looks like this may be your best bet. It looks quite intensive. I couldn't even find the docs for v2.
Dec 29, 2022, 4:04 PM
Thanks! You’ve been very helpful so far!
Dec 29, 2022, 4:05 PM
Have you tried deploying to a .sanity.studio url? Just to see if it works there.
Dec 29, 2022, 4:09 PM
Yea and that works fine
Dec 29, 2022, 4:10 PM
Then: you have not deployed it on your site… Could you find the
vercel.config
or
next.config
OR
jsconfig.json
?
Dec 29, 2022, 4:14 PM
This is my
next.config
:
module.exports = {
  images: {
    domains: ['<http://cdn.sanity.io|cdn.sanity.io>', '<http://images.unsplash.com|images.unsplash.com>'],
  },
}
Dec 29, 2022, 4:17 PM
This is my
jsconfig.json
:
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/components/*": ["components/*"],
      "@/lib/*": ["lib/*"],
      "@/context/*": ["context/*"],
      "@/hooks/*": ["hooks/*"],
    }
  }
}
Dec 29, 2022, 4:18 PM
Not sure how to access vercel.config though
Dec 29, 2022, 4:18 PM
I haven’t started the upgrade process
user J
- I will just wait to see what you have to say, but would you suggest going through and doing that?
Dec 29, 2022, 4:20 PM
And maybe the issue is that I don’t have a vercel.config file in the root of my studio directory
Dec 29, 2022, 4:22 PM
Wait never mind the above - My other client’s site doesn’t have this either, but it is working
Dec 29, 2022, 4:23 PM
Oh wait - I have a vercel.json file in the root of my Next.js directory that looks very different from the other project.Here is the current project (broken version):

// vercel.json
{
  "version": 2,
  "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}
Versus the working version:

// vercel.json
{
    "rewrites": [{ "source": "/studio/(.*)", "destination": "/studio/index.html" }]
}
Dec 29, 2022, 4:26 PM
That worked btw!
Dec 29, 2022, 5:16 PM
Nice!
Dec 29, 2022, 5:17 PM
Looks like it was looking to the root which was causing a conflict.
Dec 29, 2022, 5:18 PM
Yea that makes sense! I figured it would be something super simple haha
Dec 29, 2022, 5:18 PM
Wonderful 🙂 Sometimes a small thing can cause big issues
Dec 29, 2022, 6:46 PM
With all the different version flying around one of the files I mentioned will be the culprits 😉 And it was
Dec 29, 2022, 6:47 PM
🤝
Dec 29, 2022, 6:47 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?