Skip to content

Commit

Permalink
Merge pull request #15 from push-protocol/f_push_scan
Browse files Browse the repository at this point in the history
changes done to app and 404.html
  • Loading branch information
rohitmalhotra1420 authored Dec 3, 2024
2 parents 8a2c416 + ae194b7 commit c6008c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
15 changes: 14 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 (
<QueryClientProvider client={queryClient}>
<GlobalThemeProvider>
Expand Down
12 changes: 4 additions & 8 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<script>
var l = window.location;
window.location.href =
l.protocol +
'//' +
l.hostname +
(l.port ? ':' + l.port : '') +
'/?' +
l.pathname.slice(1);
// Redirect to the root index.html with the full path appended
const currentPath =
window.location.pathname + window.location.search + window.location.hash;
window.location.replace('/?redirect=' + encodeURIComponent(currentPath));
</script>

0 comments on commit c6008c2

Please sign in to comment.