···1213function AuthCompleteContent() {
14 const [loading, setLoading] = React.useState(true);
15- // Get all parameters from the URL
16- const currentUrl = new URL(window.location.href);
17- const params = new URLSearchParams(currentUrl.search);
00000000001819- params.forEach((value, key) => {
20- console.log(key, "=", value);
21- });
002223- // Construct the redirect URL preserving all parameters
24- const redirectUrl = `atprotobackups://auth${
25- currentUrl.search || "?" + currentUrl.hash.slice(1)
26- }`;
27- useEffect(() => {
28 // Open the URL in the system's default handler and close the window after a short delay
29- window.location.href = redirectUrl;
3031 // Close the window after a short delay to ensure the protocol handler is triggered
32 setTimeout(() => {
···1213function AuthCompleteContent() {
14 const [loading, setLoading] = React.useState(true);
15+ const [redirectUrl, setRedirectUrl] = React.useState("");
16+17+ useEffect(() => {
18+ // Only run on client side
19+ if (typeof window === "undefined") return;
20+21+ // Get all parameters from the URL
22+ const currentUrl = new URL(window.location.href);
23+ const params = new URLSearchParams(currentUrl.search);
24+25+ params.forEach((value, key) => {
26+ console.log(key, "=", value);
27+ });
2829+ // Construct the redirect URL preserving all parameters
30+ const url = `atprotobackups://auth${
31+ currentUrl.search || "?" + currentUrl.hash.slice(1)
32+ }`;
33+ setRedirectUrl(url);
340000035 // Open the URL in the system's default handler and close the window after a short delay
36+ window.location.href = url;
3738 // Close the window after a short delay to ensure the protocol handler is triggered
39 setTimeout(() => {