From f896af05cc994e179736eacb5fda11799409b223 Mon Sep 17 00:00:00 2001 From: Nycolaide Date: Sat, 30 May 2026 19:19:55 +0200 Subject: [PATCH] bug fix sitemap bad url with preprender --- .env.example | 1 + src/content/docs/environments.md | 2 +- src/routes/sitemap.xml/+server.ts | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 39e87c1e..0e585556 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ PUBLIC_DEV="true" +PUBLIC_BASE_URL="http://localhost:5173" PUBLIC_GTM_ID="" PUBLIC_GTAG_ID="" diff --git a/src/content/docs/environments.md b/src/content/docs/environments.md index 53756fad..92a1fcfd 100644 --- a/src/content/docs/environments.md +++ b/src/content/docs/environments.md @@ -1,5 +1,5 @@ --- -title: 'environments' +title: "environments" description: "Configure ESLint and TypeScript for Lapikit's custom syntax. Fix false positives, suppress ts(6133) warnings, and set up your editor for the best DX." --- diff --git a/src/routes/sitemap.xml/+server.ts b/src/routes/sitemap.xml/+server.ts index c9d7f2e5..0e1aa4ec 100644 --- a/src/routes/sitemap.xml/+server.ts +++ b/src/routes/sitemap.xml/+server.ts @@ -1,4 +1,5 @@ import { docsPaths } from '$lib'; +import { PUBLIC_BASE_URL } from '$env/static/public'; export const prerender = true; @@ -14,8 +15,8 @@ function toUrl(path: string) { return route || '/'; } -export async function GET({ request }) { - const baseUrl = new URL(request.url).origin; +export async function GET() { + const baseUrl = PUBLIC_BASE_URL.replace(/\/$/, ''); const routes = [...Object.keys(pageModules), ...Object.keys(markdownModules)] .map(toUrl)