forked from Github/frigate
Fix auth when serving Frigate at a subpath (#12815)
Ensure axios.defaults.baseURL is set when accessing login form. Drop `/api` prefix in login form's `axios.post` call, since `/api` is part of the baseURL. Redirect to subpath on succesful authentication. Prepend subpath to default logout url. Fixes #12814
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
import { baseUrl } from "../../api/baseUrl";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -43,7 +44,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
await axios.post(
|
||||
"/api/login",
|
||||
"/login",
|
||||
{
|
||||
user: values.user,
|
||||
password: values.password,
|
||||
@@ -54,7 +55,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
|
||||
},
|
||||
},
|
||||
);
|
||||
window.location.href = "/";
|
||||
window.location.href = baseUrl;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
const err = error as AxiosError;
|
||||
|
||||
Reference in New Issue
Block a user