Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshayGMZ committed Sep 20, 2024
1 parent 01fa5a7 commit 5d43214
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/server-sitemap.xml/route.ts
Original file line number Diff line number Diff line change
@@ -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 || "", {
Expand All @@ -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);
}

0 comments on commit 5d43214

Please sign in to comment.