From ae194b7ddfe4283a6216fd2357a203419bd46f94 Mon Sep 17 00:00:00 2001 From: rohitmalhotra1420 Date: Tue, 3 Dec 2024 14:57:09 +0530 Subject: [PATCH] changes done to app and 404.html --- pages/_app.tsx | 15 ++++++++++++++- public/404.html | 12 ++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index 85be7a4..0cf0cb1 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,5 +1,5 @@ // React, NextJS imports -import React from 'react'; +import React, { useEffect } from 'react'; // import localFont from '@next/font/local'; import type { AppProps } from 'next/app'; @@ -14,9 +14,22 @@ import { ThemeProvider as GlobalThemeProvider } from '../contexts/ThemeContext'; import { DataProvider } from '../contexts/DataContext'; import { QueryClient, QueryClientProvider } from 'react-query'; +import { useRouter } from 'next/dist/client/router'; const queryClient = new QueryClient(); export default function App({ Component, pageProps }: AppProps) { + const router = useRouter(); + + useEffect(() => { + // Check for the redirect parameter + const redirect = new URLSearchParams(window.location.search).get( + 'redirect' + ); + if (redirect) { + router.replace(redirect); // Navigate to the original path + } + }, [router]); + return ( diff --git a/public/404.html b/public/404.html index 47bd3f6..4f40b95 100644 --- a/public/404.html +++ b/public/404.html @@ -1,10 +1,6 @@