From a5f89d33af942c43c7c0c272b3908d1d7da2dda3 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 8 Sep 2024 20:41:26 +0200 Subject: [PATCH] fix: website URL on RSS feed is no longer determined by NODE_ENV enviornment variable --- app/rss.xml/route.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/app/rss.xml/route.ts b/app/rss.xml/route.ts index 4b42e73..976d465 100644 --- a/app/rss.xml/route.ts +++ b/app/rss.xml/route.ts @@ -6,12 +6,6 @@ import { toHTML } from "@portabletext/to-html"; export const dynamic = "force-static"; export async function GET() { - // Define the site URL based on the environment - const SITE_URL = - process.env.NODE_ENV === "production" - ? `${process.env.NEXT_PUBLIC_WEBSITE_URL}` - : "http://localhost:3000"; - const postsQuery = `*[_type == 'blog'] | order(_createdAt desc) { title, "slug": slug.current, @@ -25,9 +19,9 @@ export async function GET() { const feed = new RSS({ title: "SVR.JS Blog", description: "Explore the latest blog posts from SVR.JS", - feed_url: `${SITE_URL}/rss.xml`, - site_url: `${SITE_URL}`, - image_url: `${SITE_URL}/metadata/svrjs-cover.png`, + feed_url: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/rss.xml`, + site_url: `${process.env.NEXT_PUBLIC_WEBSITE_URL}`, + image_url: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/metadata/svrjs-cover.png`, language: "en-US", pubDate: new Date().toUTCString() }); @@ -36,12 +30,12 @@ export async function GET() { feed.item({ title: post.title, description: toHTML(post.content), - url: `${SITE_URL}/blog/${post.slug}`, + url: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/blog/${post.slug}`, date: new Date(post._createdAt).toUTCString(), enclosure: { url: post.titleImage ? urlFor(post.titleImage).url() - : `${SITE_URL}/blog-missing.png` + : `${process.env.NEXT_PUBLIC_WEBSITE_URL}/blog-missing.png` }, author: "SVR.JS" });