mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-13 18:22:49 +03:00
Return to the requested URL after logging in (#24637)
When an unauthenticated user opens a deep link, carry the requested path through the login page in a redirect query param and return to it after a successful login instead of always going to the home page. Only same-origin targets are honored. Claude-Session: https://claude.ai/code/session_011CFGjgYURSRTpXBaxp1Dq7 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
135a95d8f2
commit
e7164882f5
@@ -3,7 +3,11 @@ import { SWRConfig } from "swr";
|
||||
import { WsProvider } from "./WsProvider";
|
||||
import axios from "axios";
|
||||
import { ReactNode } from "react";
|
||||
import { isRedirectingToLogin, setRedirectingToLogin } from "./auth-redirect";
|
||||
import {
|
||||
getLoginUrl,
|
||||
isRedirectingToLogin,
|
||||
setRedirectingToLogin,
|
||||
} from "./auth-redirect";
|
||||
|
||||
axios.defaults.baseURL = `${baseUrl}api/`;
|
||||
|
||||
@@ -34,7 +38,7 @@ export function ApiProvider({ children, options }: ApiProviderType) {
|
||||
const loginPage = error.response.headers.get("location") ?? "login";
|
||||
if (window.location.href !== loginPage && !isRedirectingToLogin()) {
|
||||
setRedirectingToLogin(true);
|
||||
window.location.href = loginPage;
|
||||
window.location.href = getLoginUrl(loginPage);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user