Issue with 404 error when refreshing website at /studio/desk, resolved by updating vercel.json file.
47 replies
Last updated: Dec 29, 2022
S
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?
Can someone please explain why that might be happening?
Dec 28, 2022, 10:27 PM
S
could you share your sanity.config and your vercel.config, if you deployed it there?
Dec 29, 2022, 10:43 AM
S
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
S
I don’t know how to share the Vercel config
Dec 29, 2022, 2:03 PM
S
Which version of sanity are you using?
Dec 29, 2022, 2:49 PM
S
Regardless there should be a
vercel.config.tsfile in the root directory of the studio 🙂 (when you deploy the studio to
YOUR_DOMAIN/studiowhich it appears you do)
Dec 29, 2022, 2:50 PM
S
Interesting
Dec 29, 2022, 2:50 PM
S
This is my package json file:
Dec 29, 2022, 2:51 PM
S
{ "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
S
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
S
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
S
Hmm okay
Dec 29, 2022, 2:53 PM
S
I was thinking to check the ENV Variables, but would you suggest what else I should look into?
Dec 29, 2022, 2:53 PM
S
(On Vercel)
Dec 29, 2022, 2:53 PM
S
I’ve made a screen recording of this issue.
Dec 29, 2022, 2:57 PM
S
This is on Chrome, in incognito mode.
Dec 29, 2022, 2:57 PM
S
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)
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
K
Seems like you aren't being logged in properly.
Dec 29, 2022, 3:38 PM
S
It also seems like something super specific to this website though. Other sites don’t behave like this with the need to manually remove
/deskfrom the URL
Dec 29, 2022, 3:39 PM
K
Did you configure cors properly?
Dec 29, 2022, 3:41 PM
S
I was wondering about that too
Dec 29, 2022, 3:42 PM
S
It seems that it is setup for this site correctly
Dec 29, 2022, 3:43 PM
S
I may just try to upgrade sanity and see if that will have any positive effect
Dec 29, 2022, 3:44 PM
K
Just for kicks remove the https and replace with http in the cors setup.
Dec 29, 2022, 3:48 PM
S
Yea I got this error (Even if I try to access http):
Dec 29, 2022, 3:51 PM
K
Ah well that isn't it lol.
Dec 29, 2022, 3:52 PM
K
Have you tried it in another browser?
Dec 29, 2022, 3:52 PM
S
Yea - With Safari it just doesn’t work. Same problem with Firefox
Dec 29, 2022, 3:54 PM
K
Ok yea get the simple things out of the way first. Hmmmm
Dec 29, 2022, 3:54 PM
K
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.
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
S
Thanks! You’ve been very helpful so far!
Dec 29, 2022, 4:05 PM
K
Have you tried deploying to a .sanity.studio url? Just to see if it works there.
Dec 29, 2022, 4:09 PM
S
Yea and that works fine
Dec 29, 2022, 4:10 PM
S
Then: you have not deployed it on your site… Could you find the
vercel.configor
next.configOR
jsconfig.json?
Dec 29, 2022, 4:14 PM
S
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
S
This is my
jsconfig.json:
{ "compilerOptions": { "baseUrl": ".", "paths": { "@/components/*": ["components/*"], "@/lib/*": ["lib/*"], "@/context/*": ["context/*"], "@/hooks/*": ["hooks/*"], } } }
Dec 29, 2022, 4:18 PM
S
Not sure how to access vercel.config though
Dec 29, 2022, 4:18 PM
S
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
S
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
S
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
S
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):
Versus the working version:
// vercel.json { "version": 2, "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] }
// vercel.json { "rewrites": [{ "source": "/studio/(.*)", "destination": "/studio/index.html" }] }
Dec 29, 2022, 4:26 PM
S
That worked btw!
Dec 29, 2022, 5:16 PM
K
Nice!
Dec 29, 2022, 5:17 PM
K
Looks like it was looking to the root which was causing a conflict.
Dec 29, 2022, 5:18 PM
S
Yea that makes sense! I figured it would be something super simple haha
Dec 29, 2022, 5:18 PM
S
Wonderful 🙂 Sometimes a small thing can cause big issues
Dec 29, 2022, 6:46 PM
S
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
S
🤝
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.