Clarification on hosting the Sanity Studio on Netlify and the difference between CI/CD and serving the bundle.
6 replies
Last updated: May 4, 2020
H
☆ Hi there,I beg your pardon to bother with a probably already asked question.
I just commit my sanity installation to my Gatsby Github repo linked to Netlify deploy (Gatsby installation and setting with Netlify existed previously, before to discover and add Sanity to the project) (my Sanity project has been init from scratch, no template, nothing than cli).
Now, Netlify is acting bumping on the first data from Sanity as if not knowing it at all, which is logic as I haven't done anything in particular.
This blocks the Netlify deploy.
So I searched in the docs, I found the «hosting and deployment» page, but reading at it as carefully as possible, I do not understand the difference between the two options:
1. to «serve the bundle» to Github via Noode.js
2. and next paragraph «deploying a CI/CD flow» (what those abbreviations mean?) (Command Interface and ... ??)(Change Directory??).
Difficult to make a choice not understanding anything!
Then it says «create a token», I can do it, no worries, I have done one already.
But «remember to add
I'll appreciate if you could precise some element of information and the pro and cons of 1) and 2).
Thank you in advance ☆
I just commit my sanity installation to my Gatsby Github repo linked to Netlify deploy (Gatsby installation and setting with Netlify existed previously, before to discover and add Sanity to the project) (my Sanity project has been init from scratch, no template, nothing than cli).
Now, Netlify is acting bumping on the first data from Sanity as if not knowing it at all, which is logic as I haven't done anything in particular.
This blocks the Netlify deploy.
So I searched in the docs, I found the «hosting and deployment» page, but reading at it as carefully as possible, I do not understand the difference between the two options:
1. to «serve the bundle» to Github via Noode.js
2. and next paragraph «deploying a CI/CD flow» (what those abbreviations mean?) (Command Interface and ... ??)(Change Directory??).
Difficult to make a choice not understanding anything!
Then it says «create a token», I can do it, no worries, I have done one already.
But «remember to add
user Q
/cli as a devDependency», why not, but you mean at the level of the Github repo probably?Probably YES.I'll appreciate if you could precise some element of information and the pro and cons of 1) and 2).
Thank you in advance ☆
Apr 30, 2020, 7:36 PM
P
Hi User, cool to see that you’re getting ready to deploy to Netlify 🚀 The “CI/CD” you’re reading stand for “Continuous Integration” and “Continuous Delivery”, basically referring to two practices that let development teams deliver code changes more quickly and more easily.
That’s not necessarily important to simply deploy your project though. What’s important if you want to host your Studio on Netlify instead of *.sanity.studio, are the two steps listed on
https://www.sanity.io/docs/deployment#hosting-the-studio-elsewhere-ed3cd78ea4eb
For the first point, you could create a
The second point is about adding the Netlify domain for your Studio to your CORS settings as a valid domain for the project. You can do this by going to
manage.sanity.io > Settings > API > Add new origin. Make sure you enable the “Allow credentials” toggle.
Finally, you might have to add any environment variables that you currently have in an .env file (e.g.
After completing these steps, let’s check again if anything starts running
🤞
That’s not necessarily important to simply deploy your project though. What’s important if you want to host your Studio on Netlify instead of *.sanity.studio, are the two steps listed on
https://www.sanity.io/docs/deployment#hosting-the-studio-elsewhere-ed3cd78ea4eb
For the first point, you could create a
netlify.tomlfile in your studio root folder with the following content:
[[redirects]] from = "/*" to = "/" status = 200
manage.sanity.io > Settings > API > Add new origin. Make sure you enable the “Allow credentials” toggle.
Finally, you might have to add any environment variables that you currently have in an .env file (e.g.
env.development) as environment variables to Netlify, which doesn’t recognise the
.envfile itself. For more information on how to do so, please read the Netlify documentation: https://docs.netlify.com/configure-builds/environment-variables/
After completing these steps, let’s check again if anything starts running
🤞
Apr 30, 2020, 10:48 PM
P
Hi User, cool to see that you’re getting ready to deploy to Netlify 🚀 The “CI/CD” you’re reading stand for “Continuous Integration” and “Continuous Delivery”, basically referring to two practices that let development teams deliver code changes more quickly and more easily.
That’s not necessarily important to simply deploy your project though. What’s important if you want to host your Studio on Netlify instead of *.sanity.studio, are the two steps listed on
https://www.sanity.io/docs/deployment#hosting-the-studio-elsewhere-ed3cd78ea4eb
For the first point, you could create a
The second point is about adding the Netlify domain for your Studio to your CORS settings as a valid domain for the project. You can do this by going to
manage.sanity.io > Settings > API > Add new origin. Make sure you enable the “Allow credentials” toggle.
Finally, you might have to add any environment variables that you currently have in an .env file (e.g.
After completing these steps, let’s check again if anything starts running
🤞
That’s not necessarily important to simply deploy your project though. What’s important if you want to host your Studio on Netlify instead of *.sanity.studio, are the two steps listed on
https://www.sanity.io/docs/deployment#hosting-the-studio-elsewhere-ed3cd78ea4eb
For the first point, you could create a
netlify.tomlfile in your studio root folder with the following content:
[[redirects]] from = "/*" to = "/" status = 200
manage.sanity.io > Settings > API > Add new origin. Make sure you enable the “Allow credentials” toggle.
Finally, you might have to add any environment variables that you currently have in an .env file (e.g.
env.development) as environment variables to Netlify, which doesn’t recognise the
.envfile itself. For more information on how to do so, please read the Netlify documentation: https://docs.netlify.com/configure-builds/environment-variables/
After completing these steps, let’s check again if anything starts running
🤞
Apr 30, 2020, 10:48 PM
F
Thank you User for those explanations: it's far more clear now.Now I see what was meant by CI/CD.
Right now, i don't quite get the practical interest of hosting the studio on Netlify (it's heavier) vs not too (I would like that to be explained in the docs in terms of practices seen on the use of the studio, pro and cons) (not may be in the docs themselves but as a link where it is possible to dig that point).
Does it mean that if the studio is not hosted, Netlify is making requests to Sanity on each project build while if is, everything is internal to Netlify, there is no request?
That is probably what means «serve the bundle» noted 1) in the first post, isn't it?
If I decide not to host the studio (2), then I create a
All that is very interesting!
I beg you not to have any anger at me as I am responding on workers' day.
I would like to thank you for your help, it is a lot to me.
💫
Right now, i don't quite get the practical interest of hosting the studio on Netlify (it's heavier) vs not too (I would like that to be explained in the docs in terms of practices seen on the use of the studio, pro and cons) (not may be in the docs themselves but as a link where it is possible to dig that point).
Does it mean that if the studio is not hosted, Netlify is making requests to Sanity on each project build while if is, everything is internal to Netlify, there is no request?
That is probably what means «serve the bundle» noted 1) in the first post, isn't it?
If I decide not to host the studio (2), then I create a
netlify.tomlfile, add CORS to the project, set the
.envfile on the Netlify side.One of the interest of not hosting the studio is to keep the structure of data out of sight also no? with a private dataset, datas are json bunch of json without any schema, is that right?
All that is very interesting!
I beg you not to have any anger at me as I am responding on workers' day.
I would like to thank you for your help, it is a lot to me.
💫
May 1, 2020, 7:36 AM
P
One advantage of hosting the Studio on Netlify could be that you can pick your own domain for the Studio, although Sanity also allows you to pick your
It’s true that if you don’t have your source files for the Studio in a public repository, it is more difficult to see your schema. However, whether people can see it in the data depends on if you have your dataset set as private or as public.
I’ve noted your suggestion to clarify the pros and cons of hosting the Studio with Sanity vs. elsewhere, thanks!
🙂
<name>.sanity.studio. Where you host your Studio does not have an impact on API requests, as you will only be hosting the Studio itself as a React SPA (single page application). You will not be hosting Sanity’s content API, which is what is being used to get the data. In other words, the requests to Sanity will still have to be made even when hosting both the Studio and your web on Netlify.
It’s true that if you don’t have your source files for the Studio in a public repository, it is more difficult to see your schema. However, whether people can see it in the data depends on if you have your dataset set as private or as public.
I’ve noted your suggestion to clarify the pros and cons of hosting the Studio with Sanity vs. elsewhere, thanks!
🙂
May 1, 2020, 4:42 PM
F
Hi User,Please forgive me to respond lately I just notice your answer.
I though you guys were too busy to pay attention again.
I feel very grateful of your answer as now I perfectly get it.
And yes to clarify the pro and cons would be nice.
Thanks!
I though you guys were too busy to pay attention again.
I feel very grateful of your answer as now I perfectly get it.
And yes to clarify the pro and cons would be nice.
Thanks!
May 4, 2020, 7:42 AM
P
Thanks for confirming, User, I’m glad things are a bit clearer now 👍
May 4, 2020, 1:03 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.