From 1c8e6aa8ce93a43e2090c1d1bda303df966b0aba Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Mon, 9 Sep 2024 11:29:02 +0200 Subject: [PATCH] fix(sitemap): fetch Sanity data with token --- src/app/sitemap.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts index 6b02da5a2..73652f949 100644 --- a/src/app/sitemap.ts +++ b/src/app/sitemap.ts @@ -1,14 +1,18 @@ import type { MetadataRoute } from "next"; import { client } from "../../studio/lib/client"; import { Slug } from "../../studio/lib/payloads/global"; +import { token } from "../../studio/lib/token"; interface SitemapDocument { slug: Slug; _updatedAt: string; } +const clientWithToken = client.withConfig({ token }); + export default async function sitemap(): Promise { - const documents = await client.fetch(`*[defined(slug)]`); + const documents = + await clientWithToken.fetch(`*[defined(slug)]`); return documents.map((s) => ({ url: new URL(s.slug.current, process.env.NEXT_PUBLIC_URL).toString(),