Deploying Your Sites

AstroSanity

Space Madness was built with hosting in mind. At build time, both the Astro and Sanity Studio apps are compiled to static websites that can be hosted on almost any web service.

A Peek Under the Hood

If you'd like to learn a bit more about hosting these sites, you can do a local build and inspect the results.

# build all sites
turbo build

# build the astro site
turbo build --filter=site-space-madness-astro

#build the sanity studio site
turbo build --filter=site-space-madness-sanity

Once you've built your sites, you can look to each site's dist/ folder to see the output HTML, CSS, and JS files. Many of the files may be minified and difficult to understand, but their intended audience can read them just fine 🤖.

These are the folders that you can use to host your sites anywhere.

Deploying Your Astro Site

Astro has for a wide range of hosting options. Please follow the instructions for "static" hosting if given the option.

In general you will need three key pieces of information for hosting:

  1. Build command - turbo build --filter=site-space-madness-astro
  2. Publish directory - /apps/site-astro/dist/
  3. - SANITY_STUDIO_PROJECT_ID

Deploying Your Sanity Site

Sanity has a short but complete page on . They also offer hosting on their platform if you'd rather not deal with hosting.

Just like with deploying your Astro site, you'll need these key pieces for hosting:

  1. Build command - turbo build --filter=site-space-madness-sanity
  2. Publish directory - /apps/site-sanity/dist/
  3. - SANITY_STUDIO_PROJECT_ID

In addition, your hosting provider may need you to setup redirects for all URLs to your Sanity Studio's index.html page.

From the Sanity Studio hosting guide:

The server that delivers the Sanity Studio files needs to be configured for single-page application routing. This means if the requested URL path doesn't exist on the filesystem, it should serve index.html to allow the frontend router to handle the request. Most hosting services will have configuration options for this.

The configuration for each hosting provider will likely be different.

Space Madness supports SPA redirects for Netlify out of the box. A _redirects file is included in the root of site-sanity and copied over to the dist/ folder at build time. Check out Netlify's guide to SPA hosting.

Once you have deployed your site, the final step is to add your domain to Sanity's CORS allow list. Sanity should prompt you to do this the first time you visit the hosted site. If it does not, .