Issue with burger menu not appearing after deploying site on Vercel.
Last updated: Sep 22, 2022
Hello.I have been trying to find a solution for this. I have inherited a site based on sanity.io and nextJs. The current navigation was hardcoded and I have made the navigation on sanity using schema. Navigation appears in a burger menu. Everything is working fine in the dev. But as soon as I deploy the site on vercel, the burger menu is empty.After deploying with vercel, I am getting this Network error :
Network error while attempting to reach https://....
While there is no such error in the dev. Thanks in advance.
Yes it is. However, when I check the vercel link from CORS origins in sanity, I see my sanity menu.But in vercel deployments from my latest commits on bitcucket, the menu is not there. I also dont see the menu when I deploy the website. I am sorry, I am a new developer so there are a lot of things that I am still trying to figure out.
Sep 21, 2022, 10:28 AM
It sounds like when you deploy, your site is not longer able to connect to Sanity. There are a few reasons this happens:1. As
mentioned, your CORS origins aren't properly added to sanity.io/manage .2. You're using a token and it's not properly picked up once you deploy.
Sep 21, 2022, 3:22 PM
Another possibility is that your navigation component is rendering before it has data from Sanity, which often doesn’t show itself in development but rears its head in production.
Sep 21, 2022, 8:00 PM
Hello again. Thank you for your reply. I have tried and tested, so far I believe its not CORS or token problem because this is a big website and all the other pages are rendered succesfully.I belive its problem with my component rendering. When the website runs, I get an empty Navigation array twice, and its the third time that I get navigation items in the array. I have been playing with useEffect but still not able to solve the issue. attaching the code snippet below. Thanks in advance.
Sep 22, 2022, 8:40 AM
I have solved this issue. Thank you all for your msgs. Really helped alot. 🙏