"use client"; import { IconBrandGoogleFilled } from "@tabler/icons-react"; import { motion } from "motion/react"; import { useTranslations } from "next-intl"; import { Logo } from "@/components/Logo"; import { AmbientBackground } from "./AmbientBackground"; export function GoogleLoginButton() { const t = useTranslations("auth"); const handleGoogleLogin = () => { // IMPORTANT: // FastAPI Users OAuth stores the "state" in a cookie. // Doing a cross-origin fetch() (www.surfsense.com -> backend.ssbacktemp.xyz) // will NOT persist Set-Cookie unless you use credentials + non-wildcard CORS. // The simplest/most reliable approach is a top-level navigation to the backend // authorize endpoint so the cookie is set as first-party. const backendUrl = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL; if (!backendUrl) { console.error("Missing NEXT_PUBLIC_FASTAPI_BACKEND_URL"); return; } // This endpoint performs a 302 to Google (more reliable than fetching JSON). window.location.href = `${backendUrl}/auth/google/start`; }; return (
{t("cloud_dev_notice")}{" "} {t("docs")} {" "} {t("cloud_dev_self_hosted")}