From ddbc1a130ea1e6e98cbbad8f25a0420882593a54 Mon Sep 17 00:00:00 2001 From: Greg Rickaby Date: Tue, 12 Nov 2024 12:27:28 -0600 Subject: [PATCH] update redirect --- next.config.mjs | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/next.config.mjs b/next.config.mjs index 80873803..1ba7900b 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,13 +1,29 @@ /** @type {import('next').NextConfig} */ const nextConfig = { async redirects() { - return [ - { - source: '/r', - destination: '/', - permanent: true - } - ] + // If the app is deployed on Vercel, redirect to the custom domain. + if (process.env.VERCEL_ENV === 'production') { + return [ + { + source: '/', + destination: 'https://reddit-viewer.com/', + permanent: true + }, + { + source: '/r/:path*', + destination: 'https://reddit-viewer.com/r/:path*', + permanent: true + } + ] + } else { + return [ + { + source: '/r', + destination: '/', + permanent: true + } + ] + } }, logging: { fetches: {