Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes done to app and 404.html #15

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading