From cff91d80d4071576084078ad89b5152078acc920 Mon Sep 17 00:00:00 2001 From: Phillipp Glanz <6745190+TheMeinerLP@users.noreply.github.com> Date: Sat, 16 May 2026 12:33:31 +0200 Subject: [PATCH] fix(seo-check): do not append mock query to sitemap endpoints @nuxtjs/sitemap >= 7.5 returns an empty 204 (and a meta-refresh instead of a 307 redirect) whenever a sitemap endpoint is requested with any query string. The SEO gate appended ?mockProductionEnv to every localhost request, which made the sitemap appear empty and failed the check after the sitemap dependency bump. The sitemap output is environment-independent, so the mock query is now skipped for sitemap URLs while robots.txt and page meta still exercise the production mock. --- scripts/seo-check.mjs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/seo-check.mjs b/scripts/seo-check.mjs index 1fac420..59c30e4 100644 --- a/scripts/seo-check.mjs +++ b/scripts/seo-check.mjs @@ -71,13 +71,21 @@ const colorise = (level, text) => { return `${codes[level] || ''}${text}\x1b[0m` } +// @nuxtjs/sitemap >= 7.5 serves an empty 204 (and a meta-refresh instead of a +// 307) whenever the sitemap endpoints are requested with *any* query string, +// so the mock-prod query must not be appended to sitemap URLs. The sitemap is +// environment-independent here anyway; only robots.txt and page meta need the +// production mock. +const isSitemapPath = (pathname) => + /^\/(sitemap[^/]*\.xml|sitemap_index\.xml|__sitemap__\/)/i.test(pathname) + /** * Builds a URL relative to BASE and adds the dev mock-prod query when * targeting localhost so we exercise the production robots/sitemap path. */ const buildUrl = (path) => { const url = new URL(path, BASE) - if (USE_MOCK && !url.searchParams.has('mockProductionEnv')) { + if (USE_MOCK && !isSitemapPath(url.pathname) && !url.searchParams.has('mockProductionEnv')) { url.searchParams.set('mockProductionEnv', '') } return url