From 5a4b67d83e1fd9711c782a52f1398f6eb74f2a25 Mon Sep 17 00:00:00 2001 From: Eugene Fox Date: Tue, 22 Oct 2024 22:35:05 +0000 Subject: [PATCH] fix: robots.txt and sitemap.xml using env on build time only --- app/robots.ts | 4 +++- app/sitemap.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/robots.ts b/app/robots.ts index cc79c0e..e1984c1 100644 --- a/app/robots.ts +++ b/app/robots.ts @@ -1,12 +1,14 @@ import { MetadataRoute } from "next"; +import { unstable_noStore } from "next/cache"; import { canonicalName } from "./_data/metadata"; export default function robots(): MetadataRoute.Robots { + unstable_noStore(); return { rules: { userAgent: "*", - allow: [ "/$", "/resume" ], + allow: [ "/$", "/resume", "/sitemap.xml" ], disallow: [ "/resume/download", "/" ], }, sitemap: new URL("/sitemap.xml", canonicalName.href).href, diff --git a/app/sitemap.ts b/app/sitemap.ts index 50eefce..0d578ba 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -1,8 +1,10 @@ import { MetadataRoute } from "next"; +import { unstable_noStore } from "next/cache"; import { canonicalName } from "./_data/metadata"; export default function sitemap(): MetadataRoute.Sitemap { + unstable_noStore(); return [ { url: canonicalName.href,