···12121313function AuthCompleteContent() {
1414 const [loading, setLoading] = React.useState(true);
1515- // Get all parameters from the URL
1616- const currentUrl = new URL(window.location.href);
1717- const params = new URLSearchParams(currentUrl.search);
1515+ const [redirectUrl, setRedirectUrl] = React.useState("");
1616+1717+ useEffect(() => {
1818+ // Only run on client side
1919+ if (typeof window === "undefined") return;
2020+2121+ // Get all parameters from the URL
2222+ const currentUrl = new URL(window.location.href);
2323+ const params = new URLSearchParams(currentUrl.search);
2424+2525+ params.forEach((value, key) => {
2626+ console.log(key, "=", value);
2727+ });
18281919- params.forEach((value, key) => {
2020- console.log(key, "=", value);
2121- });
2929+ // Construct the redirect URL preserving all parameters
3030+ const url = `atprotobackups://auth${
3131+ currentUrl.search || "?" + currentUrl.hash.slice(1)
3232+ }`;
3333+ setRedirectUrl(url);
22342323- // Construct the redirect URL preserving all parameters
2424- const redirectUrl = `atprotobackups://auth${
2525- currentUrl.search || "?" + currentUrl.hash.slice(1)
2626- }`;
2727- useEffect(() => {
2835 // Open the URL in the system's default handler and close the window after a short delay
2929- window.location.href = redirectUrl;
3636+ window.location.href = url;
30373138 // Close the window after a short delay to ensure the protocol handler is triggered
3239 setTimeout(() => {