From bcf329ff674ffda63525eb33f572244e4ac1c0c5 Mon Sep 17 00:00:00 2001 From: gluzzati Date: Fri, 22 Mar 2024 11:38:58 +0000 Subject: [PATCH] also router.redirect --- frontend/src/components/auth/SignUpForm.tsx | 6 ++++-- frontend/src/pages/auth/signIn.tsx | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/auth/SignUpForm.tsx b/frontend/src/components/auth/SignUpForm.tsx index 50a9f97..71f7d9c 100644 --- a/frontend/src/components/auth/SignUpForm.tsx +++ b/frontend/src/components/auth/SignUpForm.tsx @@ -19,6 +19,8 @@ import useUser from "../../hooks/user.hook"; import authService from "../../services/auth.service"; import toast from "../../utils/toast.util"; +const webroot = process.env.WEBROOT || ""; + const SignUpForm = () => { const config = useConfig(); const router = useRouter(); @@ -52,9 +54,9 @@ const SignUpForm = () => { .then(async () => { const user = await refreshUser(); if (user?.isAdmin) { - router.replace("/admin/intro"); + router.replace(webroot + "/admin/intro"); } else { - router.replace("/upload"); + router.replace(webroot + "/upload"); } }) .catch(toast.axiosError); diff --git a/frontend/src/pages/auth/signIn.tsx b/frontend/src/pages/auth/signIn.tsx index c30ec11..faafb81 100644 --- a/frontend/src/pages/auth/signIn.tsx +++ b/frontend/src/pages/auth/signIn.tsx @@ -7,6 +7,8 @@ import Meta from "../../components/Meta"; import useUser from "../../hooks/user.hook"; import useTranslate from "../../hooks/useTranslate.hook"; +const webroot = process.env.WEBROOT || ""; + export function getServerSideProps(context: GetServerSidePropsContext) { return { props: { redirectPath: context.query.redirect ?? null }, @@ -25,7 +27,7 @@ const SignIn = ({ redirectPath }: { redirectPath?: string }) => { useEffect(() => { refreshUser().then((user) => { if (user) { - router.replace(redirectPath ?? "/upload"); + router.replace(redirectPath ?? webroot + "/upload"); } else { setIsLoading(false); }