https://github.com/rishi-raj-jain/edgio-sanity-studio-example
A template to deploy Sanity Studio (v2) with Edgio seamlessly
https://github.com/rishi-raj-jain/edgio-sanity-studio-example
edgio sanity-studio
Last synced: 14 days ago
JSON representation
A template to deploy Sanity Studio (v2) with Edgio seamlessly
- Host: GitHub
- URL: https://github.com/rishi-raj-jain/edgio-sanity-studio-example
- Owner: rishi-raj-jain
- Created: 2021-07-04T14:47:50.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T15:52:12.000Z (about 2 years ago)
- Last Synced: 2024-10-12T13:36:26.937Z (4 months ago)
- Topics: edgio, sanity-studio
- Language: JavaScript
- Homepage: https://layer0-docs-layer0-sanity-studio-example-default.layer0-limelight.link/desk
- Size: 2.24 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deploying Sanity Studio with Edgio
## By [Rishi Raj Jain](https://rishi.app)
Sanity Studio is a single page app (SPA) written in React, where you can configure the document types and input fields, with simple JavaScript objects. This guide will walk you through how to deploy Sanity Studio with Edgio in four simple steps.

## Step 1: Setting Up your Sanity Studio Project
**NOTE:** You can skip this step if you already have a project set up.
First, install the [Sanity CLI](https://www.npmjs.com/package/@sanity/cli):
```bash
npm i -g @sanity/cli
```To initiate a new project and download the Studio code to your computer, run the following in the command line:
```bash
sanity init
```The Sanity CLI will walk you through the necessary steps to set up a project, letting you choose a schema template. When you're done with these steps, the CLI will download the source code and configuration to get you started. To start a local development server, `cd` into the project folder and run the following command:
```bash
sanity start
```## Step 2: Preparing for Deployment
First, install the [Edgio CLI](https://www.npmjs.com/package/@edgio/cli):
```bash
npm install -g @edgio/cli
```To add Edgio to an existing app, run the following:
```bash
edgio init --connector=@edgio/sanity-studio
```The above command creates routes.ts and edgio.config.js. Replace the content in routes.ts by the following:
```ts
import { Router } from '@edgio/core'
import { sanityRoutes } from '@edgio/sanity-studio'export default new Router({ indexPermalink: false }).use(sanityRoutes)
```After saving your `routes.ts` file you will be ready to deploy your project.
## Step 3: Preview Production Locally With Edgio
To preview production app locally run:
```bash
edgio build && edgio run --production
```## Step 4: Deploy With Edgio
To deploy run:
```
edgio deploy
```Once Sanity Studio is deployed, you will need to add it's URL to Sanity’s [CORS origins](https://www.sanity.io/docs/front-ends/cors) settings. You can do this from the command line:
`sanity cors add https://your-url.layer0-limelight.link --credentials`
Alternatively, you can navigate to [manage.sanity.io](https://manage.sanity.io/), find your project and under Settings > API, add the Studio URL to the CORS origins list. You should allow credentials as the Studio requires authentication for added security.