Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

404 When Hosting Sanity on Netlify

3 replies
Last updated: Nov 17, 2021

This might be a noob question, but we are struggling with 404 when hosting Sanity on Netlify.
When visiting the site it will redirect to

/desk
. For example in Safari you’ll get the cookie not accepted dialog and after clicking all of the login and ok buttons we’ll end up on a Page Not Found page. The same can happen in other browsers as well, but it’s possible to “fix” it by going to the root of the hosted url (deleting /desk from the path)
Do we need to define some redirects or something here?

Nov 17, 2021, 2:31 PM

Hi Jørn - not a noob question!
This is because it's missing a single-page app routing configuration - if the file/path requested cannot be found, it should fallback to the root (

index.html
).
A
netlify.toml
like the following usually does the trick:

[[redirects]]
  from = "/*"
  to = "/"
  status = 200

Nov 17, 2021, 2:47 PM

That did indeed solve the problem. Thank you!

Nov 17, 2021, 3:53 PM

Great 🙂

Nov 17, 2021, 4:06 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.