From 993126cfa584588a3bedf08fb95ed783520d8714 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Sat, 14 Oct 2023 14:46:11 +0300 Subject: [PATCH] apps/web: fix replace location after login --- apps/web/components/Form.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/components/Form.jsx b/apps/web/components/Form.jsx index f62988d..fa5c969 100644 --- a/apps/web/components/Form.jsx +++ b/apps/web/components/Form.jsx @@ -5,13 +5,11 @@ import Error from 'elements/Error'; import { H3 } from 'elements/H'; import Input from 'elements/Input'; import getConfig from 'next/config'; -import { useRouter } from 'next/router'; import { useState } from 'react'; const { publicRuntimeConfig: config } = getConfig(); export default function Form() { - const router = useRouter(); const [hasError, setHasError] = useState(false); const error = hasError ? Неверный логин или пароль : null; @@ -28,7 +26,11 @@ export default function Form() { axios .post('/signin', data) .then(() => { - router.reload(); + const url = + (window.location.pathname.replace(config.basePath, '') || '/') + + (window.location.search || ''); + + window.location.replace(url); }) .catch(() => { setHasError(true);