diff --git a/next-sitemap.config.js b/next-sitemap.config.js index 171800da..2294842c 100644 --- a/next-sitemap.config.js +++ b/next-sitemap.config.js @@ -1,4 +1,13 @@ module.exports = { siteUrl: process.env.NEXT_PUBLIC_DEFAULT_SITE_URL || 'http://localhost:3000', generateRobotsTxt: true, + exclude: ['/redirect', '/redirect/*'], + robotsTxtOptions: { + policies: [ + { + userAgent: '*', + disallow: ['/redirect', '/redirect/*'], + }, + ], + }, }; diff --git a/src/app/(website)/layout.tsx b/src/app/(website)/layout.tsx index 5a36075a..2932785f 100644 --- a/src/app/(website)/layout.tsx +++ b/src/app/(website)/layout.tsx @@ -74,6 +74,12 @@ async function RootLayout({ children }: { children: React.ReactNode }) { document.head.appendChild(script); } + function loadHandleInitialPageUrl() { + if (!localStorage.getItem('initialPageUrl')) { + localStorage.setItem('initialPageUrl', window.location.href); + } + } + void 0 === window._axcb && (window._axcb = []); window._axcb.push(function (axeptio) { axeptio.on("ready", function() { @@ -89,6 +95,9 @@ async function RootLayout({ children }: { children: React.ReactNode }) { if (choices.clearbit) { loadClearbit(); } + if (choices.initialPageUrl) { + loadHandleInitialPageUrl(); + } }); }); `} diff --git a/src/app/(website)/redirect/page.tsx b/src/app/(website)/redirect/page.tsx new file mode 100644 index 00000000..7577917f --- /dev/null +++ b/src/app/(website)/redirect/page.tsx @@ -0,0 +1,35 @@ +'use client'; + +import { useRouter, useSearchParams } from 'next/navigation'; + +import { Suspense, useEffect } from 'react'; + +import LoadingIcon from '@/svgs/icons/loading.inline.svg'; + +function RedirectComponent() { + const router = useRouter(); + const searchParams = useSearchParams(); + const url = searchParams.get('url'); + + useEffect(() => { + if (url) { + router.push(url); + } + }, [url, router]); + + return ( +