diff --git a/app/server-sitemap.xml/route.ts b/app/server-sitemap.xml/route.ts index 38bcf3d..c2a504c 100644 --- a/app/server-sitemap.xml/route.ts +++ b/app/server-sitemap.xml/route.ts @@ -1,5 +1,7 @@ import { getServerSideSitemap, getServerSideSitemapIndex, ISitemapField } from "next-sitemap"; import { neon } from "@neondatabase/serverless"; +import { NextRequest } from "next/server"; +import { hostname } from "os"; async function getData() { const sql = neon(process.env.SITEMAP_DB_URI || "", { @@ -10,12 +12,12 @@ async function getData() { )); } -export async function GET(request: Request) { +export async function GET(request: NextRequest) { const pages = (await getData())[0].reltuples; const resultArray = Array.from( { length: Math.ceil(pages/25000) }, - (_, i) => `/${i}/sitemap.xml` + (_, i) => `${request.nextUrl.origin}/${i}/sitemap.xml` ); - + // This should work return getServerSideSitemapIndex(resultArray); }