From 1689039c39a65265e06a00546e82faae51ca3cac Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Tue, 15 Apr 2025 07:53:11 +0000 Subject: [PATCH] Merged in fix/sitemap-route (pull request #1801) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: sitemap - now the route works * Fix: sitemap - now the route works Approved-by: Joakim Jäderberg --- apps/scandic-web/app/sitemap/[sitemapId]/route.ts | 3 +++ apps/scandic-web/app/sitemap/route.ts | 9 +++++++++ apps/scandic-web/middleware.ts | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/scandic-web/app/sitemap/[sitemapId]/route.ts b/apps/scandic-web/app/sitemap/[sitemapId]/route.ts index 1af4f382f..2dbe19f4e 100644 --- a/apps/scandic-web/app/sitemap/[sitemapId]/route.ts +++ b/apps/scandic-web/app/sitemap/[sitemapId]/route.ts @@ -17,6 +17,9 @@ export async function GET( } const sitemapId = context.params.sitemapId + + console.log("[SITEMAP] Fetching sitemap by ID", sitemapId) + if (!sitemapId) { notFound() } diff --git a/apps/scandic-web/app/sitemap/route.ts b/apps/scandic-web/app/sitemap/route.ts index 84e9d484d..70a992c4f 100644 --- a/apps/scandic-web/app/sitemap/route.ts +++ b/apps/scandic-web/app/sitemap/route.ts @@ -11,9 +11,18 @@ export async function GET() { notFound() } + console.log(`[SITEMAP] Fetching sitemap`) + const lastUpdated = await getLastUpdated() + const sitemaps = await getSitemapIds() + if (!sitemaps || sitemaps.length === 0) { + return new Response("No sitemaps found", { status: 404 }) + } + + console.log(`[SITEMAP] Sitemaps retrieved: ${sitemaps.length}`) + const urls = sitemaps.map( (id) => ` ${env.PUBLIC_URL}/sitemap-${id}.xml diff --git a/apps/scandic-web/middleware.ts b/apps/scandic-web/middleware.ts index cad34e08b..b3ecafd82 100644 --- a/apps/scandic-web/middleware.ts +++ b/apps/scandic-web/middleware.ts @@ -125,5 +125,5 @@ export const config = { * public routes inside middleware. * (https://clerk.com/docs/quickstarts/nextjs?utm_source=sponsorship&utm_medium=youtube&utm_campaign=code-with-antonio&utm_content=12-31-2023#add-authentication-to-your-app) */ - matcher: ["/((?!.+\\.[\\w]+$|_next|_static|.netlify|api|trpc).*)"], + matcher: ["/((?!.+\\.[\\w]+$|_next|_static|.netlify|api|trpc|sitemap).*)"], }