Support basePath in all queries.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { Formik, Form, Field } from 'formik';
|
||||
import Router from 'next/router';
|
||||
import { useRouter } from 'next/router';
|
||||
import { post } from 'lib/web';
|
||||
import Button from 'components/common/Button';
|
||||
import FormLayout, {
|
||||
@@ -28,13 +28,17 @@ const validate = ({ username, password }) => {
|
||||
};
|
||||
|
||||
export default function LoginForm() {
|
||||
const router = useRouter();
|
||||
const [message, setMessage] = useState();
|
||||
|
||||
const handleSubmit = async ({ username, password }) => {
|
||||
const { ok, status, data } = await post('/api/auth/login', { username, password });
|
||||
const { ok, status, data } = await post(`${router.basePath}/api/auth/login`, {
|
||||
username,
|
||||
password,
|
||||
});
|
||||
|
||||
if (ok) {
|
||||
await Router.push('/');
|
||||
return router.push('/');
|
||||
} else {
|
||||
setMessage(
|
||||
status === 401 ? (
|
||||
|
||||
Reference in New Issue
Block a user