From 70d7516b8eabbca6f8d7cd8f5ce4bc68f0636b55 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Thu, 26 Sep 2024 02:52:44 -0400 Subject: [PATCH] enhance --- app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 3e20a25..508f6c2 100644 --- a/app.js +++ b/app.js @@ -313,9 +313,15 @@ app.get('/rss', (req, res) => { res.send(rssFeed); }); +// Create a URL object from the environment variable +const blog_URL = new URL(process.env.BLOG_URL); + +// Extract just the hostname (e.g., blog.raven-scott.fyi) +const hostname = blog_URL.hostname; + // Global 404 handler for unmatched routes app.use((req, res) => { - if (req.hostname === 'blog.raven-scott.fyi') { + if (req.hostname === hostname) { res.redirect(process.env.HOST_URL); } else { res.redirect('/');