diff options
| author | Ahmet Kilinc <akx9@icloud.com> | 2025-07-16 01:05:42 +0100 |
|---|---|---|
| committer | Ahmet Kilinc <akx9@icloud.com> | 2025-07-16 01:05:42 +0100 |
| commit | ece9c78b16acd683f09b0fcd7c7b515c64da52f9 (patch) | |
| tree | d6bc7096bcb465fbcf1867d9b112035949dbe455 /apps/web/src/components | |
| parent | eb49500592e5c50c5637c09ea585b065545f2135 (diff) | |
| download | opencut-ece9c78b16acd683f09b0fcd7c7b515c64da52f9.tar.gz | |
coderabbit comments
Diffstat (limited to 'apps/web/src/components')
| -rw-r--r-- | apps/web/src/components/landing/hero.tsx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/apps/web/src/components/landing/hero.tsx b/apps/web/src/components/landing/hero.tsx index 54aba300..b1910dc5 100644 --- a/apps/web/src/components/landing/hero.tsx +++ b/apps/web/src/components/landing/hero.tsx @@ -16,16 +16,24 @@ export function Hero() { const [csrfToken, setCsrfToken] = useState<string | null>(null); useEffect(() => { + let isMounted = true; fetch("/api/waitlist/token", { credentials: "include", }) .then((res) => res.json()) .then((data) => { - if (data.token) { + if (isMounted && data.token) { setCsrfToken(data.token); } }) - .catch((err) => console.error("Failed to fetch CSRF token:", err)); + .catch((err) => { + console.error("Failed to fetch CSRF token:", err); + if (isMounted) { + toast.error("Security initialization failed", { + description: "Please refresh the page to continue.", + }); + } + }); }, []); const handleSubmit = async (e: React.FormEvent) => { @@ -70,6 +78,9 @@ export function Hero() { .then((res) => res.json()) .then((data) => { if (data.token) setCsrfToken(data.token); + }) + .catch((err) => { + console.error("Failed to refresh CSRF token:", err); }); } else { toast.error("Oops!", { |
