diff --git a/astro/src/components/SanityLive.astro b/astro/src/components/SanityLive.astro index 5bd9999..0eed793 100644 --- a/astro/src/components/SanityLive.astro +++ b/astro/src/components/SanityLive.astro @@ -1,12 +1,12 @@ \ No newline at end of file + error: (error: unknown) => { + if (error instanceof CorsOriginError) { + console.warn( + `Sanity Live is unable to connect to the Sanity API as the current origin - ${window.origin} - is not in the list of allowed CORS origins for this Sanity Project.`, + error.addOriginUrl && `Add it here:`, + error.addOriginUrl?.toString(), + ) + } else { + console.error(error) + } + }, + }) + window.addEventListener('beforeunload', () => subscription.unsubscribe()) + diff --git a/astro/src/layouts/Layout.astro b/astro/src/layouts/Layout.astro index a9e87e8..17483ea 100644 --- a/astro/src/layouts/Layout.astro +++ b/astro/src/layouts/Layout.astro @@ -1,6 +1,6 @@ --- -import { ClientRouter } from 'astro:transitions'; -import SanityLive from '../components/SanityLive.astro'; +import {ClientRouter} from 'astro:transitions' +import SanityLive from '../components/SanityLive.astro' --- diff --git a/astro/src/pages/index.astro b/astro/src/pages/index.astro index d934207..f8f0782 100644 --- a/astro/src/pages/index.astro +++ b/astro/src/pages/index.astro @@ -1,8 +1,8 @@ --- import {defineQuery} from 'groq' -import {sanityFetch} from '../sanity/fetch' import Welcome from '../components/Welcome.astro' import Layout from '../layouts/Layout.astro' +import {sanityFetch} from '../sanity/fetch' export const prerender = false