From fac9f0ba916553c645f7dd6ee01c02a202dfb4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CSebastian?= <64795732+slegarraga@users.noreply.github.com> Date: Thu, 6 Aug 2026 03:51:14 -0400 Subject: [PATCH] refactor: use getSiteUrl helper for URL construction --- app/(public)/agent/[slug]/page.tsx | 4 ++-- app/(public)/case/[caseNumber]/page.tsx | 6 ++---- app/(public)/tag/[slug]/page.tsx | 4 ++-- app/feed.xml/route.ts | 4 ++-- app/robots.ts | 4 ++-- app/sitemap.ts | 4 ++-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/(public)/agent/[slug]/page.tsx b/app/(public)/agent/[slug]/page.tsx index 649d7fa..81f2fbd 100644 --- a/app/(public)/agent/[slug]/page.tsx +++ b/app/(public)/agent/[slug]/page.tsx @@ -5,6 +5,7 @@ import { PostCard } from "@/components/post/PostCard"; import { EmptyState } from "@/components/ui/EmptyState"; import { AGENTS } from "@/lib/constants/agents"; import { fetchPostsByAgent } from "@/lib/db/posts"; +import { getSiteUrl } from "@/lib/utils/urls"; export const revalidate = 60; @@ -17,8 +18,7 @@ export async function generateMetadata({ }: PageProps): Promise { const agent = AGENTS.find((a) => a.slug === params.slug); if (!agent) return { title: "Agent Not Found" }; - const siteUrl = - process.env.NEXT_PUBLIC_SITE_URL ?? "https://agentpostmortem.com"; + const siteUrl = getSiteUrl(); const ogImageUrl = `${siteUrl}/api/og/agent/${params.slug}`; return { title: `${agent.name} Failure Cases`, diff --git a/app/(public)/case/[caseNumber]/page.tsx b/app/(public)/case/[caseNumber]/page.tsx index 26634bd..273ff73 100644 --- a/app/(public)/case/[caseNumber]/page.tsx +++ b/app/(public)/case/[caseNumber]/page.tsx @@ -41,8 +41,7 @@ export async function generateMetadata({ const title = post ? post.title : `Case ${caseNum}`; const description = post?.outcome?.slice(0, 160) ?? `AI agent failure case file ${caseNum}`; - const siteUrl = - process.env.NEXT_PUBLIC_SITE_URL ?? "https://agentpostmortem.com"; + const siteUrl = getSiteUrl(); const ogImageUrl = `${siteUrl}/api/og/${caseNum}`; return { @@ -132,8 +131,7 @@ export default async function CasePage({ params }: PageProps) { : `$${post.estimatedCostUsd}` : null; - const siteUrl = - process.env.NEXT_PUBLIC_SITE_URL ?? "https://agentpostmortem.com"; + const siteUrl = getSiteUrl(); const sourceDomain = getSourceDomain(post.sourceUrl); const articleJsonLd = { "@context": "https://schema.org", diff --git a/app/(public)/tag/[slug]/page.tsx b/app/(public)/tag/[slug]/page.tsx index 2f84063..0439b16 100644 --- a/app/(public)/tag/[slug]/page.tsx +++ b/app/(public)/tag/[slug]/page.tsx @@ -5,6 +5,7 @@ import { PostCard } from "@/components/post/PostCard"; import { EmptyState } from "@/components/ui/EmptyState"; import { TAGS } from "@/lib/constants/tags"; import { fetchPostsByTag } from "@/lib/db/posts"; +import { getSiteUrl } from "@/lib/utils/urls"; export const revalidate = 60; @@ -17,8 +18,7 @@ export async function generateMetadata({ }: PageProps): Promise { const tag = TAGS.find((t) => t.slug === params.slug); if (!tag) return { title: "Tag Not Found" }; - const siteUrl = - process.env.NEXT_PUBLIC_SITE_URL ?? "https://agentpostmortem.com"; + const siteUrl = getSiteUrl(); const ogImageUrl = `${siteUrl}/api/og/tag/${params.slug}`; return { title: `#${tag.label} — AI Agent Failures`, diff --git a/app/feed.xml/route.ts b/app/feed.xml/route.ts index 6379464..ee7883f 100644 --- a/app/feed.xml/route.ts +++ b/app/feed.xml/route.ts @@ -1,11 +1,11 @@ import { createSupabaseAdminClient } from "@/lib/supabase/admin"; +import { getSiteUrl } from "@/lib/utils/urls"; export const dynamic = "force-dynamic"; export const revalidate = 3600; export async function GET() { - const siteUrl = - process.env.NEXT_PUBLIC_SITE_URL ?? "https://agentpostmortem.com"; + const siteUrl = getSiteUrl(); const supabase = createSupabaseAdminClient(); const { data: posts } = await supabase diff --git a/app/robots.ts b/app/robots.ts index 6a8e6c9..8eae56d 100644 --- a/app/robots.ts +++ b/app/robots.ts @@ -1,8 +1,8 @@ import { MetadataRoute } from "next"; +import { getSiteUrl } from "@/lib/utils/urls"; export default function robots(): MetadataRoute.Robots { - const siteUrl = - process.env.NEXT_PUBLIC_SITE_URL ?? "https://agentpostmortem.com"; + const siteUrl = getSiteUrl(); return { rules: { userAgent: "*", diff --git a/app/sitemap.ts b/app/sitemap.ts index 929c513..fb87672 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -2,12 +2,12 @@ import { MetadataRoute } from "next"; import { createSupabaseAdminClient } from "@/lib/supabase/admin"; import { AGENTS } from "@/lib/constants/agents"; import { TAGS } from "@/lib/constants/tags"; +import { getSiteUrl } from "@/lib/utils/urls"; export const dynamic = "force-dynamic"; export default async function sitemap(): Promise { - const siteUrl = - process.env.NEXT_PUBLIC_SITE_URL ?? "https://agentpostmortem.com"; + const siteUrl = getSiteUrl(); const supabase = createSupabaseAdminClient(); const { data: posts } = await supabase