Skip to content

Commit ad14db1

Browse files
committed
[With AI] add better error handlign
1 parent 3f2d8d2 commit ad14db1

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

app/routes/auth/ott.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ export default function Ott() {
2727
setLoading(false);
2828
} else {
2929
toast.success("Logged in");
30-
navigate(new URL(redirect || "").pathname);
30+
if (redirect && redirect.trim() !== "") {
31+
try {
32+
const redirectUrl = new URL(redirect);
33+
navigate(redirectUrl.pathname);
34+
} catch {
35+
// If redirect is not a valid URL, treat it as a relative path
36+
navigate(redirect);
37+
}
38+
} else {
39+
navigate("/");
40+
}
3141
}
3242
} catch (error) {
3343
setMessage("Something went wrong");

0 commit comments

Comments
 (0)