Troubleshooting deployment and login issues with self-hosted Sanity instance
9 replies
Last updated: Feb 23, 2022
J
Running into some weird development and deployment issues with a self-hosted version of Sanity.So I have my studio deployed at a subdomain
I am using the
When I spin up Netlify Dev, the Studio app returns what's in the posted image, but still remains accessible at its application
When it's deployed to Netlify itself, I am getting prompted for Sanity login that resolves to a
This still doesn't give me the expected result of being able to login to the
Any help would be greatly appreciated.
<http://studio.mysite.com|studio.mysite.com>and the site it serves content to @
<http://www.mysite.com|www.mysite.com>.
I am using the
netlify/clito run a local dev instance which proxy's from a
targetPort: 3333or the Sanity Studio application to the Netlify dev exposed
port: 9090which is also setup as a CORS whitelisted URL on Sanity. This is supposed to mimic deployment on Netlify.
When I spin up Netlify Dev, the Studio app returns what's in the posted image, but still remains accessible at its application
port:3333.
When it's deployed to Netlify itself, I am getting prompted for Sanity login that resolves to a
Page Not Foundmessage. In order to try an fix that, I have a
netlify.tomlfiles that does the redirects for SPA apps like so.
[[ redirects ]] from = "/*" to = "/index.html" status = 200
productionor
developinstances of the studio app.I am bit stumped as to why this is not working as I feel I have had this setup the same way in past project tests. I have double checked all my CORS settings as well as my local configurations and still can't find a way to troubleshoot this.
Any help would be greatly appreciated.
Feb 17, 2022, 10:27 PM
J
Ok I got my production environment working by switching off my Brave browser shields. So effectively a cookie was stopping my
productiondeploys, but I still can't figure out why my local Netlify Dev instance will gives me the
SyntaxError: Unexpected token '<'
Feb 17, 2022, 11:32 PM
A
Hey Jonathon. You are redirecting all requests to
That's just a guess
🙂. Are you able to see any more details in your console about which specific request or file is leading to this error?
/index.html. Based on the error, I'm guessing that Sanity is trying to load a JS or JSON file, but your server is instead providing
index.html—which is not a valid script file.
That's just a guess
🙂. Are you able to see any more details in your console about which specific request or file is leading to this error?
Feb 18, 2022, 10:25 AM
J
Hey
Thanks again!
user E
thanks for that! I turned off the redirects and it seemed to do the trick. For some reason I was getting a Page Not Foundon Netlify and thought this
netlify.tomlmight be the solution. I guess it wasn’t….😅
Thanks again!
Feb 18, 2022, 5:47 PM
J
Alright, so after deploying without the redirects.I pulls up the login to Sanity prompt, but when I click on my preferred login method, I get whats in the image.
Feb 18, 2022, 9:30 PM
J
Kind of stumped, not sure what’s going on exactly that makes it so I cannot login to my production instances, or develop instances. All my CORS origin settings are correct.
Feb 18, 2022, 9:38 PM
J
Ahh! Cookies once again! Shoot!
Feb 18, 2022, 9:41 PM
A
The redirect is required, but I initially wondered whether it was preventing other files from being served. I just checked the Netlify docs, and this is not the case. By default, a Netlify redirect will respect existing paths .
You do need the redirect. Removing it is probably why you're now getting a
Sorry for leading you down the wrong path, but at least we've now eliminated one possible cause of this issue
🙂.
The next questions I'd like to ask are:
1. Do you have the latest version of
the Netlify CLI installed?2. Does the
You do need the redirect. Removing it is probably why you're now getting a
404after signing in.
Sorry for leading you down the wrong path, but at least we've now eliminated one possible cause of this issue
🙂.
The next questions I'd like to ask are:
1. Do you have the latest version of
the Netlify CLI installed?2. Does the
SyntaxError: Unexpected token '<'error occur both locally and on Netlify?3. Does the
SyntaxError: Unexpected token '<'error occur when running your Studio locally using the
sanity startcommand (instead of using the Netlify CLI)?
Feb 21, 2022, 9:30 AM
J
Thanks for following up
user E
. Turned out to be aggressive Cookie blocking in Brave that was the issue. Seems to be working ok now.Feb 22, 2022, 9:53 PM
A
Great, I'm glad you got this working! And I'm sorry for the cookie issues.
Feb 23, 2022, 10:35 AM
Sanity– build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.