page.tsx 648 B

12345678910111213141516171819202122232425
  1. 'use client';
  2. import { useRouter, usePathname } from 'next/navigation';
  3. import { useEffect, useState } from 'react';
  4. export default function NotFound() {
  5. const router = useRouter();
  6. const pathname = usePathname();
  7. const [loading, setLoading] = useState(true);
  8. useEffect(() => {
  9. const validRoutes = ['/', '/demo', '/gallery', '/img2img', '/inpainting', '/settings', '/text2img', '/upscaler'];
  10. if (validRoutes.includes(pathname)) {
  11. router.push(pathname);
  12. } else {
  13. setLoading(false);
  14. }
  15. }, [pathname, router]);
  16. if (loading) {
  17. return <div>Loading...</div>;
  18. }
  19. return <div>404 - Page not found</div>;
  20. }