+19
-12
docs/app/auth/complete/page.tsx
+19
-12
docs/app/auth/complete/page.tsx
···
12
12
13
13
function AuthCompleteContent() {
14
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);
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
+
});
18
28
19
-
params.forEach((value, key) => {
20
-
console.log(key, "=", value);
21
-
});
29
+
// Construct the redirect URL preserving all parameters
30
+
const url = `atprotobackups://auth${
31
+
currentUrl.search || "?" + currentUrl.hash.slice(1)
32
+
}`;
33
+
setRedirectUrl(url);
22
34
23
-
// Construct the redirect URL preserving all parameters
24
-
const redirectUrl = `atprotobackups://auth${
25
-
currentUrl.search || "?" + currentUrl.hash.slice(1)
26
-
}`;
27
-
useEffect(() => {
28
35
// Open the URL in the system's default handler and close the window after a short delay
29
-
window.location.href = redirectUrl;
36
+
window.location.href = url;
30
37
31
38
// Close the window after a short delay to ensure the protocol handler is triggered
32
39
setTimeout(() => {