fix(frontend): disable Cloudflare on Vercel previews (#10354)

## Changes 🏗️

Disable the Cloudflare check:

<img width="600" height="861" alt="Screenshot 2025-07-11 at 18 51 46"
src="https://github.com/user-attachments/assets/792ecca0-967e-4cef-a562-789125452d2f"
/>

On Vercel previews, so we can use previews for testing Front-end only
changes.

Vercel previews have dynamically generated URLs:
```
https://{branch}-{commit}-significant-gravitas.vercel.app/login
```

So if Cloudflare does not support URL wildcards we will neeed to do this
🙇🏽 ( _as an experiment_ )

## Checklist 📋

### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
  - [x] You can login on the preview
  
### For configuration changes:

None
This commit is contained in:
Ubbe
2025-07-14 14:27:56 +04:00
committed by GitHub
parent 0b6e46d363
commit a789f87734
3 changed files with 32 additions and 3 deletions

View File

@@ -28,6 +28,11 @@ export default isDevelopmentBuild
org: "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 CI
silent: !process.env.CI,

View File

@@ -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);

View File

@@ -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",