1
0
Fork 0

also router.redirect

This commit is contained in:
gluzzati 2024-03-22 11:38:58 +00:00
parent 7d4fc04add
commit bcf329ff67
2 changed files with 7 additions and 3 deletions

View File

@ -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);

View File

@ -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);
}