diff --git a/apps/scandic-web/app/api/web/sitemap/utils.ts b/apps/scandic-web/app/api/web/sitemap/utils.ts
index eeeb59884..af7711f8a 100644
--- a/apps/scandic-web/app/api/web/sitemap/utils.ts
+++ b/apps/scandic-web/app/api/web/sitemap/utils.ts
@@ -20,10 +20,22 @@ export function mergeEntries(
const entries = [...currentEntries]
newEntries.forEach((entry) => {
- const index = entries.findIndex(
- ({ data }) =>
- data.uid === entry.data.uid && data.locale === entry.data.locale
- )
+ if (!entry?.data?.uid || !entry?.data?.locale) {
+ metricsEntriesMerge.dataError(
+ `Invalid entry data, missing uid or locale`,
+ { entry }
+ )
+ return
+ }
+
+ const index = entries.findIndex(({ data }) => {
+ if (!data) {
+ metricsEntriesMerge.dataError(`Data is null or undefined,`)
+ return false
+ }
+
+ return data.uid === entry.data.uid && data.locale === entry.data.locale
+ })
if (index > -1) {
entries[index] = entry
} else {
diff --git a/apps/scandic-web/app/sitemap/[sitemapId]/route.ts b/apps/scandic-web/app/sitemap/[sitemapId]/route.ts
index cf6ffb511..b42182aaf 100644
--- a/apps/scandic-web/app/sitemap/[sitemapId]/route.ts
+++ b/apps/scandic-web/app/sitemap/[sitemapId]/route.ts
@@ -49,6 +49,6 @@ export async function GET(
const sitemapXML = `\n${entries.join("")}\n`
return new Response(sitemapXML, {
- headers: { "Content-Type": "text/xml" },
+ headers: { "Content-Type": "application/xml" },
})
}
diff --git a/apps/scandic-web/app/sitemap/route.ts b/apps/scandic-web/app/sitemap/route.ts
index 802eb6e41..76042dbc2 100644
--- a/apps/scandic-web/app/sitemap/route.ts
+++ b/apps/scandic-web/app/sitemap/route.ts
@@ -33,6 +33,6 @@ export async function GET() {
const sitemapIndexXML = `\n${urls.join("")}\n`
return new Response(sitemapIndexXML, {
- headers: { "Content-Type": "text/xml" },
+ headers: { "Content-Type": "application/xml" },
})
}