Blog sitemap

React / Next.js

Serve /blog.xml from your React framework by proxying the Rootscript project sitemap.

Setup steps

  1. 1Create a route that responds at /blog.xml on your production domain.
  2. 2Fetch the Rootscript project sitemap URL shown in your dashboard popup.
  3. 3Return the fetched XML with an application/xml content type and no long-lived cache.
  4. 4Click Check solution in Rootscript to verify the live URL.

Next.js App Router example

Replace YOUR_SITE_ID with the site id from the Rootscript sitemap URL shown in your dashboard popup.

export const dynamic = "force-dynamic";

export async function GET() {
  const res = await fetch("https://rootscript.io/api/site/YOUR_SITE_ID/sitemap.xml", {
    cache: "no-store",
  });

  if (!res.ok) {
    return new Response("Sitemap unavailable", { status: 502 });
  }

  return new Response(await res.text(), {
    headers: {
      "Content-Type": "application/xml; charset=utf-8",
      "Cache-Control": "no-store, max-age=0",
    },
  });
}