AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): disable Cloudflare on Vercel previews (#10354)
Ubbea789f877347d
diff --git a/autogpt_platform/frontend/next.config.mjs b/autogpt_platform/frontend/next.config.mjsindex b7f2f0b3fb..c1b3168041 100644--- a/autogpt_platform/frontend/next.config.mjs+++ b/autogpt_platform/frontend/next.config.mjs@@ -28,6 +28,11 @@ export default isDevelopmentBuildorg: "significant-gravitas",project: "builder",+ // Expose Vercel env to the client+ env: {+ NEXT_PUBLIC_VERCEL_ENV: process.env.VERCEL_ENV,+ },+// Only print logs for uploading source maps in CIsilent: !process.env.CI,diff --git a/autogpt_platform/frontend/src/app/(platform)/login/useLoginPage.ts b/autogpt_platform/frontend/src/app/(platform)/login/useLoginPage.tsindex 02f1e24963..430e2d5fe6 100644--- a/autogpt_platform/frontend/src/app/(platform)/login/useLoginPage.ts+++ b/autogpt_platform/frontend/src/app/(platform)/login/useLoginPage.ts@@ -20,6 +20,7 @@ export function useLoginPage() {const [isGoogleLoading, setIsGoogleLoading] = useState(false);const [showNotAllowedModal, setShowNotAllowedModal] = useState(false);const isCloudEnv = getBehaveAs() === BehaveAs.CLOUD;+ const isVercelPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === "preview";const turnstile = useTurnstile({action: "login",@@ -47,6 +48,17 @@ export function useLoginPage() {async function handleProviderLogin(provider: LoginProvider) {setIsGoogleLoading(true);+ if (!turnstile.verified && !isVercelPreview) {+ toast({+ title: "Please complete the CAPTCHA challenge.",+ variant: "info",+ });++ setIsGoogleLoading(false);+ resetCaptcha();+ return;+ }+try {const error = await providerLogin(provider);if (error) throw error;@@ -65,10 +77,10 @@ export function useLoginPage() {async function handleLogin(data: z.infer<typeof loginFormSchema>) {setIsLoading(true);- if (!turnstile.verified) {+ if (!turnstile.verified && !isVercelPreview) {toast({title: "Please complete the CAPTCHA challenge.",- variant: "default",+ variant: "info",});setIsLoading(false);diff --git a/autogpt_platform/frontend/src/app/(platform)/signup/useSignupPage.ts b/autogpt_platform/frontend/src/app/(platform)/signup/useSignupPage.tsindex b3409a70bc..b7cbd7d1af 100644--- a/autogpt_platform/frontend/src/app/(platform)/signup/useSignupPage.ts+++ b/autogpt_platform/frontend/src/app/(platform)/signup/useSignupPage.ts@@ -22,6 +22,7 @@ export function useSignupPage() {const [showNotAllowedModal, setShowNotAllowedModal] = useState(false);const isCloudEnv = getBehaveAs() === BehaveAs.CLOUD;+ const isVercelPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === "preview";const turnstile = useTurnstile({action: "signup",@@ -50,6 +51,17 @@ export function useSignupPage() {async function handleProviderSignup(provider: LoginProvider) {setIsGoogleLoading(true);++ if (!turnstile.verified && !isVercelPreview) {+ toast({+ title: "Please complete the CAPTCHA challenge.",+ variant: "default",+ });+ setIsGoogleLoading(false);+ resetCaptcha();+ return;+ }+const error = await providerLogin(provider);if (error) {setIsGoogleLoading(false);@@ -66,7 +78,7 @@ export function useSignupPage() {async function handleSignup(data: z.infer<typeof signupFormSchema>) {setIsLoading(true);- if (!turnstile.verified) {+ if (!turnstile.verified && !isVercelPreview) {toast({title: "Please complete the CAPTCHA challenge.",variant: "default",