Unlock seamless workflows and faster delivery with our latest releases – get the details

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– 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?