Tips for running a Studio locally with the Netlify CLI and resolving CORS error.
8 replies
Last updated: Mar 20, 2021
J
Anyone have tips for running a Studio locally with the netlify CLI? I want to ship functions with the studio and need to develop them locally, but I get a "Not Found" printed in the DOM (no console errs) when running "netlify dev" in the studio root. Here's the netlify.toml
[[redirects]] from = "/*" to = "/" status = 200 [build] functions = "functions" base = "studio" publish = "studio/dist" command = "npm run build"
Feb 28, 2021, 6:53 PM
Hi!The Netlify CLI can automatically identify the framework used. But Sanity is not on the list. You need to add the configuration manually to netlify.toml, something like this
[dev] command = "yarn dev" port = 8888 targetPort = 3333 publish = "dist" autoLaunch = true framework = "#custom"
Mar 1, 2021, 7:10 AM
You can find more info in the netlify doc: https://docs.netlify.com/configure-builds/file-based-configuration/#netlify-dev
Mar 1, 2021, 7:11 AM
J
Thanks User! I’ll give this a try
Mar 1, 2021, 2:36 PM
J
Finally getting back to this project and I'm a bit confused as to how the netlify dev environment is supposed to have sanity/core installed in order to run sanity start?
user S
the config you sent is definitely appropriate and starts up the server, but then I see this error@sanity/core not installed in current project Project-specific commands not available until you run `sanity install` Error: "start" is not available outside of a Sanity project context. Run the command again within a Sanity project directory, where "@sanity/core" is installed as a dependency.
Mar 20, 2021, 3:15 AM
strange, I've just tried running ntl dev and it works for me. but I didn't try the serverless functions:
Mar 20, 2021, 10:03 AM
Mar 20, 2021, 10:04 AM
J
simply forgot to install dependancies 😅 got the studio running with Netlify CLI now, however I get a Sanity CORS error when trying to open the studio on the Netlify defined port (8888). I can open it through the targetPort (3333) though. I have both 8888 and 3333 defined in the Sanity API settings, but I'm still getting this cors error. Weird!
Mar 20, 2021, 7:21 PM
J
Moved localhost:8888 to "Allow Credentials" and got the studio to open properly! Thanks again
user S
Mar 20, 2021, 7:31 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.