How to host both Sanity Studio and Frontend on the same Netlify site
13 replies
Last updated: May 14, 2021
O
Hey people! how does hosting both your sanity studio and your FE on the same netlify site work? I did find a guide on the guide page but it returned 404. I got the FE up and running but i’d like to access the studio on the same url but like /admin or /dashboard or whatever 🙂 everything is in the same github repo
May 13, 2021, 8:47 AM
Hey Oskar! The process for deploying should be the same as in this guide .You would need to make sure that you’ve configured single-page application routing on Netlify and added the domain where you’re hosting the Studio as a
valid domain in manage.sanity.io . Then, you would specify the
valid domain in manage.sanity.io . Then, you would specify the
basePathin
sanity.jsonas
/adminor
/dashboard
May 13, 2021, 6:23 PM
And as a side note, you could add this plugin to easily trigger new builds of your FE from your dashboard!
May 13, 2021, 6:25 PM
Hey Oskar! The process for deploying should be the same as in this guide .You would need to make sure that you’ve configured single-page application routing on Netlify and added the domain where you’re hosting the Studio as a
valid domain in manage.sanity.io . Then, you would specify the
valid domain in manage.sanity.io . Then, you would specify the
basePathin
sanity.jsonas
/adminor
/dashboard
May 13, 2021, 6:23 PM
O
Hey
how would i go on to setup the build settings for the netlify site?
user M
, thanks for the answer 😄Im not really sure how that would work considering i have to specify the build command and the publish directory.. and if i have a project repo and the structure for it isproject/ web/ studio/
May 14, 2021, 7:43 PM
O
Might just be me who doesnt understand it, because atm to only build the FE i set the baseDirectory to
/weband the build command to
next build && next exportand then the publish directory to
/web/outSo i dont know how to get the sanity folder
/studiointo that solution..
May 14, 2021, 7:46 PM
OK, if I’m understanding correctly, you’re not sure how to get the studio to build at the domain you specify?
If so, you would follow the steps in the guide I shared above then run
Let me know if I’m getting your goal wrong!
If so, you would follow the steps in the guide I shared above then run
sanity deployin order to have the studio deploy. You wouldn’t need to include the studio in your next build.
Let me know if I’m getting your goal wrong!
May 14, 2021, 9:07 PM
O
Okay so what you’re saying is that if i have my github repository (including both the
/weband
/studio) on netlify and the build settings is what i stated before, e.g the commands to build the nextjs application, I dont have to do
sanity buildif i want to be able to access the studio on the same netlify url but on
websiteUrl/admin? I just have to deploy with a specified build path in sanity.json?
May 14, 2021, 9:15 PM
O
Okay so what you’re saying is that if i have my github repository (including both the
/weband
/studio) on netlify and the build settings is what i stated before, e.g the commands to build the nextjs application, I dont have to do
sanity buildif i want to be able to access the studio on the same netlify url but on
websiteUrl/admin? I just have to deploy with a specified build path in sanity.json?
May 14, 2021, 9:15 PM
O
Do i have to state the full url or just /admin in the build path?
May 14, 2021, 9:16 PM
It would just be the /admin build path but you would have to add the domain to your CORS origins in manage.sanity.io
May 14, 2021, 9:19 PM
O
alright sweet! 😄 Thank you so much🤗
May 14, 2021, 9:19 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.