I want to redirect from a custom 404 page to the home page with locale in the URL.
E.g: if the users type wrong URL localhost:3000/ja/news/wrong-uri user will be redirected to localhost:3000/ja/.
The problem is when nextjs redirect to custom a 404-page router.locale always equal 'vi' which is the default locale.
Btw my website use next build and next export (everything is static)
Please help
const Custom404 = () => {
const router = useRouter();
useEffect(() => {
console.log(router);
router.replace(`/${router.locale}/`);
});
return null;
};
export default Custom404;