diff --git a/.env.example b/.env.example
index 2f10c58..f493284 100644
--- a/.env.example
+++ b/.env.example
@@ -31,21 +31,10 @@ CATALOG_ADMIN_SECRET=REPLACE_WITH_32_CHAR_HEX
ALLOWED_ORIGIN=http://localhost:3000
# ---------------------------------------------------------------------------
-# Firebase Client SDK Configuration (Required for Live Client Auth)
-# Obtain from: Firebase Console > Project Settings > General > Your apps (Web)
+# Cloudflare Turnstile Bot & Abuse Protection
+# Obtain from: Cloudflare Dashboard > Turnstile > Add Widget
+# Test Site Key (Always Passes): 1x00000000000000000000AA
+# Test Secret Key (Always Passes): 1x0000000000000000000000000000000AA
# ---------------------------------------------------------------------------
-NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key_here
-NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com
-NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
-NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com
-NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
-NEXT_PUBLIC_FIREBASE_APP_ID=1:your_app_id:web:your_web_id
-NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=G-XXXXXXXXXX
-
-# ---------------------------------------------------------------------------
-# Firebase Admin SDK Configuration (Required for Server Session Minting)
-# Obtain from: Firebase Console > Project Settings > Service accounts > Generate new private key
-# ---------------------------------------------------------------------------
-FIREBASE_PROJECT_ID=your_project_id
-FIREBASE_CLIENT_EMAIL=firebase-adminsdk-xxxxx@your_project_id.iam.gserviceaccount.com
-FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC....\n-----END PRIVATE KEY-----\n"
+NEXT_PUBLIC_TURNSTILE_SITE_KEY=your_cloudflare_turnstile_site_key
+CLOUDFLARE_TURNSTILE_SECRET_KEY=your_cloudflare_turnstile_secret_key
diff --git a/CLOUDFLARE_TURNSTILE_SETUP.md b/CLOUDFLARE_TURNSTILE_SETUP.md
new file mode 100644
index 0000000..2b6fd26
--- /dev/null
+++ b/CLOUDFLARE_TURNSTILE_SETUP.md
@@ -0,0 +1,80 @@
+# Cloudflare Turnstile Integration & Activation Guide
+
+This document explains how to activate and manage **Cloudflare Turnstile** bot protection on the CRE Innovations Web Studio platform.
+
+Firebase Authentication has been completely replaced with **Cloudflare Turnstile**, providing frictionless, privacy-preserving bot and abuse protection across all AI inference tools and forms.
+
+---
+
+## ⚡ Quick Activation (2 Minutes)
+
+To activate Cloudflare Turnstile, follow these simple steps:
+
+### Step 1: Open Cloudflare Dashboard
+1. Go to the [Cloudflare Dashboard](https://dash.cloudflare.com/).
+2. Log in (or create a free Cloudflare account if you don't have one).
+
+### Step 2: Create a Turnstile Widget
+1. In the left navigation menu, click **Turnstile** (under Application Services).
+2. Click **Add widget** (or **Add site**).
+3. Fill in the widget details:
+ - **Widget name**: `CRE Innovations Studio` (or any name you prefer).
+ - **Domains**:
+ - Add `localhost` (for local development and testing).
+ - Add your production domain (e.g., `creinnovations.in` or `yourdomain.com`).
+ - Add staging / preview domains if applicable (e.g. `*.vercel.app`).
+ - **Widget Mode**:
+ - Select **Managed** *(Recommended)*: Cloudflare decides when to run an invisible background check vs. showing an interactive checkbox based on risk level.
+ - Or select **Non-interactive** / **Invisible** based on your security preference.
+4. Click **Create**.
+
+### Step 3: Copy Your Keys
+Cloudflare will display two keys:
+1. **Site Key** (Public, starts with `0x4AAAAAA...`)
+2. **Secret Key** (Private, starts with `0x4AAAAAA...`)
+
+### Step 4: Add Keys to `.env.local`
+In the root directory of `WEBB` (and `WEBB_EDITOR` if running separately), open or create `.env.local` and add:
+
+```env
+# Cloudflare Turnstile Keys
+NEXT_PUBLIC_TURNSTILE_SITE_KEY=your_copied_site_key_here
+CLOUDFLARE_TURNSTILE_SECRET_KEY=your_copied_secret_key_here
+```
+
+### Step 5: Restart the Server
+Restart the Next.js process:
+```bash
+npm run build && npm run start
+```
+Done! Cloudflare Turnstile is now active and protecting all AI inference calls against automated bots and scrapers.
+
+---
+
+## 🧪 Testing Locally (Zero Setup Test Keys)
+
+Cloudflare provides official testing keys so you can test all scenarios immediately without needing a Cloudflare account:
+
+| Scenario | Site Key (Public) | Secret Key (Server) | Expected Behavior |
+| :--- | :--- | :--- | :--- |
+| **Always Passes** | `1x00000000000000000000AA` | `1x0000000000000000000000000000000AA` | Automatically passes verification without interaction. |
+| **Always Fails / Blocks** | `2x00000000000000000000AB` | `2x0000000000000000000000000000000AA` | Verification always fails; server rejects with HTTP 403. |
+| **Interactive Challenge** | `3x00000000000000000000FF` | `1x0000000000000000000000000000000AA` | Forces user to click the verification checkbox. |
+
+> [!NOTE]
+> If neither `NEXT_PUBLIC_TURNSTILE_SITE_KEY` nor `CLOUDFLARE_TURNSTILE_SECRET_KEY` is set in `.env.local`, the app defaults to the **Always Passes** test key in development so you are never locked out during development.
+
+---
+
+## 🛡️ Architecture & Verification Flow
+
+1. **Client**:
+ - The user opens a tool workspace (e.g. `/tools/blemish-remover`).
+ - The lightweight `` loads dynamically from `challenges.cloudflare.com`.
+ - Upon successful verification, a temporary token `cf-turnstile-response` is generated.
+2. **Execution**:
+ - When the user clicks **Process / Run**, `cf-turnstile-response` is included in the multipart `FormData` sent to `/api/try/[toolId]`.
+3. **Server Verification**:
+ - `/api/try/[toolId]` validates the token against `https://challenges.cloudflare.com/turnstile/v0/siteverify` using `CLOUDFLARE_TURNSTILE_SECRET_KEY`.
+ - If verification succeeds, GPU inference proceeds.
+ - If verification fails or is omitted by a bot, the request is immediately rejected with HTTP `403 BOT_VERIFICATION_FAILED`.
diff --git a/FIREBASE_SETUP.md b/FIREBASE_SETUP.md
deleted file mode 100644
index 7e861ec..0000000
--- a/FIREBASE_SETUP.md
+++ /dev/null
@@ -1,229 +0,0 @@
-# Complete Firebase Authentication Setup & Post-Implementation Guide
-
-This comprehensive runbook details everything you need to do in the **Firebase Console**, **Google Cloud Platform**, and your **Hosting Environment** to take the authentication system live.
-
-All code, cryptographic session handling, CSRF protections, UI modals, and fallback states are already fully implemented. Follow this checklist to complete the credentials and security setup.
-
----
-
-## 📋 Executive Checklist
-
-- [ ] **Step 1:** Create or select your Firebase Project.
-- [ ] **Step 2:** Enable Sign-In Methods (Google & Email/Password).
-- [ ] **Step 3:** Configure Google Cloud OAuth Consent Screen (Production Mode).
-- [ ] **Step 4:** Whitelist Authorized Domains.
-- [ ] **Step 5:** Retrieve Client SDK Config & Paste into `.env.local`.
-- [ ] **Step 6:** Generate Admin Service Account Private Key & Paste into `.env.local`.
-- [ ] **Step 7:** Customize Authentication Email Templates.
-- [ ] **Step 8:** Enable Account Enumeration Protection (Anti-Scraping).
-- [ ] **Step 9:** Restart & Perform End-to-End Verification.
-- [ ] **Step 10:** Production Deployment Setup (Vercel, Railway, VPS, etc.).
-
----
-
-## 1. Firebase Project Setup
-
-1. Navigate to the [Firebase Console](https://console.firebase.google.com/).
-2. Click **Add project** (or select your existing project).
-3. Name your project (e.g., `cre-innovations-studio`).
-4. Google Analytics can be enabled or disabled based on your preference (if enabled, you'll receive a `NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID`).
-5. Click **Create project** and wait for provisioning to complete.
-
----
-
-## 2. Enable Authentication Providers
-
-1. In the left navigation menu, go to **Build** > **Authentication**.
-2. Click **Get Started** if Authentication is not yet activated.
-3. In the **Sign-in method** tab:
- - **Google**:
- 1. Click **Google** under Additional providers.
- 2. Toggle **Enable**.
- 3. Enter a **Public-facing name for project** (e.g., `CRE Innovations Studio`).
- 4. Select your **Project support email** from the dropdown.
- 5. Click **Save**.
- - **Email/Password**:
- 1. Click **Email/Password** under Native providers.
- 2. Toggle **Email/Password** to **Enable**.
- 3. Leave *Email link (passwordless sign-in)* disabled unless explicitly required.
- 4. Click **Save**.
-
----
-
-## 3. Configure Google Cloud OAuth Consent Screen (Critical)
-
-> [!IMPORTANT]
-> If this step is skipped, users outside your workspace or developer account will receive an "Access Blocked / Unverified App" error when attempting Google Sign-In.
-
-1. Open the [Google Cloud Console](https://console.cloud.google.com/) with the same Google account.
-2. Select your Firebase project from the top project selector dropdown.
-3. In the navigation menu, go to **APIs & Services** > **OAuth consent screen**.
-4. If prompted, select User Type **External** and click **Create**.
-5. Fill in the required fields:
- - **App name**: `CRE Innovations Studio`
- - **User support email**: Your support or admin email.
- - **Developer contact information**: Your contact email.
- - *(Optional)* Upload your app logo and links to Privacy Policy / Terms of Service.
-6. Click **Save and Continue** through the Scopes step (standard `openid`, `email`, `profile` are pre-selected).
-7. Under **Publishing status**:
- - If it says **Testing**, only specific test users can sign in.
- - Click **Publish App** to switch to **In production** so any user can authenticate with Google.
-
----
-
-## 4. Whitelist Authorized Domains
-
-Firebase blocks OAuth popups from unlisted origins to prevent phishing:
-
-1. In the Firebase Console, go to **Authentication** > **Settings** tab.
-2. Click **Authorized domains**.
-3. Verify that `localhost` is listed (included by default).
-4. Click **Add domain** and enter your production and staging domains:
- - Your production domain (e.g. `creinnovations.com` or `studio.creinnovations.com`)
- - Your deployment host domain (e.g. `your-app.vercel.app` or `your-app.up.railway.app`)
-
----
-
-## 5. Retrieve Client Web SDK Keys
-
-1. In the Firebase Console, click the **Settings gear icon ⚙️** (top left) > **Project settings**.
-2. In the **General** tab, scroll down to the **Your apps** card.
-3. If no web app exists:
- - Click the **Web icon `>`**.
- - Enter an App nickname (e.g., `CRE Studio Web`).
- - Do **not** check "Also set up Firebase Hosting" (since this Next.js app is hosted independently).
- - Click **Register app**.
-4. Under **SDK setup and configuration**, select **Config**.
-5. Copy the configuration values into your local `.env.local` file:
-
-```env
-NEXT_PUBLIC_FIREBASE_API_KEY=AIzaSy...
-NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=cre-innovations-studio.firebaseapp.com
-NEXT_PUBLIC_FIREBASE_PROJECT_ID=cre-innovations-studio
-NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=cre-innovations-studio.appspot.com
-NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=123456789012
-NEXT_PUBLIC_FIREBASE_APP_ID=1:123456789012:web:abcdef123456
-NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=G-XXXXXXXXXX
-```
-
----
-
-## 6. Generate Admin SDK Service Account Keys (Zero-Loophole Security)
-
-The server requires service account credentials to verify ID tokens, set cryptographically signed `httpOnly` session cookies, and protect against XSS token theft:
-
-1. In **Project settings**, click the **Service accounts** tab.
-2. Confirm **Firebase Admin SDK** is selected (Node.js snippet displayed).
-3. Click **Generate new private key** and confirm the dialog.
-4. A JSON key file (e.g., `cre-innovations-studio-firebase-adminsdk-xxxxx.json`) will download to your machine.
-5. Open the downloaded file in a text editor and extract the three fields into `.env.local`:
-
-```env
-FIREBASE_PROJECT_ID=cre-innovations-studio
-FIREBASE_CLIENT_EMAIL=firebase-adminsdk-xxxxx@cre-innovations-studio.iam.gserviceaccount.com
-FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC...\n-----END PRIVATE KEY-----\n"
-```
-
-> [!CAUTION]
-> - Never commit `.env.local` or the downloaded JSON file to Git.
-> - Ensure the `FIREBASE_PRIVATE_KEY` is wrapped in double quotes and keeps the `\n` characters intact. Our code automatically handles replacing `\n` strings with real line breaks.
-
----
-
-## 7. Customize Authentication Email Templates
-
-Make sure outbound emails reflect your brand:
-
-1. In Firebase Console, go to **Authentication** > **Templates** tab.
-2. Select **Password reset**:
- - Click the pencil icon to edit.
- - Customize the **Sender name** (e.g. `CRE Innovations Studio`).
- - Set **Reply-to** address.
- - Adjust message subject and body if desired.
-3. Select **Email address verification**:
- - Customize sender name and reply-to address.
-4. *(Optional / Recommended for Custom Domain Branding)*:
- - Click the edit icon next to **From** address to configure your custom domain email (via Mailgun, SendGrid, or custom SMTP/DNS records) so emails don't come from `@firebaseapp.com`.
-
----
-
-## 8. Anti-Abuse & Account Enumeration Protection
-
-1. In Firebase Console, go to **Authentication** > **Settings** tab.
-2. Under **User actions**, verify that **Email enumeration protection** is **Enabled**.
- - This prevents attackers from guessing whether an email is registered by returning identical response codes.
-3. Under **Authorized domains**, ensure unneeded domains are not present.
-
----
-
-## 9. Local Verification Checklist
-
-Once your `.env.local` file contains all keys:
-
-1. **Restart your server**:
- ```bash
- cd /home/creserver/Desktop/WEBB
- npm run build && npm run start
- # or for development:
- # npm run dev
- ```
-2. **Open the browser** at `http://localhost:3000`.
-3. **Verify the UI**:
- - Click the **Sign In** button in the top navbar.
- - Notice the amber "Firebase not configured" banner is now **gone**.
- - You should see the sleek dark-glass Sign In modal with Google OAuth and Email/Password fields.
-4. **Test Email/Password Flow**:
- - Switch to **Create account** tab.
- - Enter a test email and password (minimum 8 characters with at least one number).
- - Click **Create Account**.
- - Verify that you are signed in, the modal closes, and the Navbar shows your user avatar dropdown.
-5. **Inspect the Session Cookie**:
- - Open Chrome DevTools > **Application** tab > **Cookies** > `http://localhost:3000`.
- - Confirm that `__session` is present and marked `HttpOnly` and `SameSite: Lax`.
-6. **Test Google Sign-In**:
- - Click your avatar > **Sign Out**.
- - Click **Sign In** > **Continue with Google**.
- - Select your Google account in the popup.
- - Confirm you are logged in and your Google profile photo / name appears in the UserMenu.
-7. **Verify in Firebase Console**:
- - Go to **Authentication** > **Users** tab.
- - Confirm your registered test users appear with their correct Provider, Created, and Last Signed In timestamps.
-
----
-
-## 10. Production Deployment Setup (Vercel, Railway, Docker, etc.)
-
-When deploying to production:
-
-1. **Add Environment Variables**:
- In your hosting dashboard (e.g., Vercel Project Settings > Environment Variables), add all keys:
- - `NEXT_PUBLIC_FIREBASE_API_KEY`
- - `NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN`
- - `NEXT_PUBLIC_FIREBASE_PROJECT_ID`
- - `NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET`
- - `NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID`
- - `NEXT_PUBLIC_FIREBASE_APP_ID`
- - `NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID`
- - `FIREBASE_PROJECT_ID`
- - `FIREBASE_CLIENT_EMAIL`
- - `FIREBASE_PRIVATE_KEY`
-
- > **Vercel / Multi-line Variable Tip**: When pasting `FIREBASE_PRIVATE_KEY` in Vercel or cloud dashboards, you can paste the entire string including `\n` or the raw multiline PEM block. The app's `formatPrivateKey` normalizer automatically sanitizes either format.
-
-2. **Add Production URL to Authorized Domains**:
- - In Firebase Console > **Authentication** > **Settings** > **Authorized domains**, add your final domain (`https://creinnovations.com`).
-
-3. **Verify HTTPS**:
- - In production (`NODE_ENV === 'production'`), the session cookie automatically sets the `Secure` flag. HTTPS is required for the session cookie to be stored by the browser.
-
----
-
-## 11. Common Troubleshooting
-
-| Issue | Cause | Fix |
-|---|---|---|
-| `auth/unauthorized-domain` | Current domain not in whitelist | Add domain to Firebase Console > Authentication > Settings > Authorized domains. |
-| `auth/popup-blocked` | Browser blocked Google OAuth popup | Allow popups for your domain or test in standard browser window. |
-| "Access blocked: This app's request is invalid" | OAuth consent screen not configured | Complete Step 3 in Google Cloud Console > APIs & Services > OAuth consent screen. |
-| "Admin token verification failed" | Malformed `FIREBASE_PRIVATE_KEY` | Ensure `FIREBASE_PRIVATE_KEY` is wrapped in double quotes in `.env.local` with `\n` escapes intact. |
-| Session cookie missing after refresh | HTTP used instead of HTTPS in production | Ensure your production host has SSL/HTTPS enabled; cookies enforce `Secure` in production. |
diff --git a/package.json b/package.json
index b9bbff3..9de127a 100644
--- a/package.json
+++ b/package.json
@@ -11,8 +11,6 @@
"dependencies": {
"@types/three": "^0.187.0",
"clsx": "^2.1.1",
- "firebase": "^13.3.0",
- "firebase-admin": "^14.5.1",
"framer-motion": "^14.9.0",
"lenis": "^1.3.27",
"lucide-react": "^0.468.0",
diff --git a/src/app/api/auth/session/route.ts b/src/app/api/auth/session/route.ts
deleted file mode 100644
index a6012f0..0000000
--- a/src/app/api/auth/session/route.ts
+++ /dev/null
@@ -1,140 +0,0 @@
-import { NextRequest, NextResponse } from 'next/server';
-import {
- createFirebaseSessionCookie,
- verifyFirebaseIdToken,
- isFirebaseAdminConfigured,
-} from '@/lib/firebase/admin';
-import { getServerUser, SESSION_COOKIE_NAME } from '@/lib/firebase/serverAuth';
-
-/**
- * Validates that requests come from the same origin to mitigate CSRF attacks.
- * In production, the Origin header MUST be present and match the host.
- */
-function isValidOrigin(req: NextRequest): boolean {
- const origin = req.headers.get('origin');
- const host = req.headers.get('host');
-
- if (!host) return false;
-
- // In production, always require an Origin header on mutating requests
- if (process.env.NODE_ENV === 'production') {
- if (!origin) return false;
- try {
- const originUrl = new URL(origin);
- return originUrl.host === host;
- } catch {
- return false;
- }
- }
-
- // In development, allow missing Origin (e.g. curl / local testing)
- if (!origin) return true;
-
- try {
- const originUrl = new URL(origin);
- return originUrl.host === host;
- } catch {
- return false;
- }
-}
-
-/**
- * POST /api/auth/session
- * Securely creates an httpOnly session cookie after client authentication.
- */
-export async function POST(req: NextRequest) {
- if (!isValidOrigin(req)) {
- return NextResponse.json({ error: 'Invalid origin / CSRF rejection' }, { status: 403 });
- }
-
- try {
- const body = await req.json().catch(() => ({}));
- const idToken = body.idToken;
-
- if (!idToken || typeof idToken !== 'string') {
- return NextResponse.json({ error: 'Valid idToken required' }, { status: 400 });
- }
-
- const res = NextResponse.json({ success: true });
-
- const fiveDaysInMs = 60 * 60 * 24 * 5 * 1000;
- const isProduction = process.env.NODE_ENV === 'production';
-
- if (isFirebaseAdminConfigured()) {
- // Cryptographically mint a Firebase Session Cookie
- const sessionCookie = await createFirebaseSessionCookie(idToken, fiveDaysInMs);
-
- if (sessionCookie) {
- res.cookies.set(SESSION_COOKIE_NAME, sessionCookie, {
- maxAge: Math.floor(fiveDaysInMs / 1000),
- httpOnly: true,
- secure: isProduction,
- path: '/',
- sameSite: 'lax',
- });
- return res;
- }
-
- // Could not mint a server cookie even though admin is configured — reject
- return NextResponse.json({ error: 'Session creation failed' }, { status: 500 });
- }
-
- // Admin SDK not configured: verify the ID token signature directly (dev mode only)
- if (isProduction) {
- return NextResponse.json({ error: 'Auth backend not configured' }, { status: 503 });
- }
-
- // Fallback: Dev only — store raw ID token with 1-hour expiry
- res.cookies.set(SESSION_COOKIE_NAME, idToken, {
- maxAge: 3600,
- httpOnly: true,
- secure: false,
- path: '/',
- sameSite: 'lax',
- });
-
- return res;
- } catch (error: any) {
- console.error('[Auth API] Session creation error:', error);
- return NextResponse.json(
- { error: 'Failed to create session' },
- { status: 500 }
- );
- }
-}
-
-/**
- * DELETE /api/auth/session
- * Clears the session cookie on logout.
- */
-export async function DELETE(req: NextRequest) {
- if (!isValidOrigin(req)) {
- return NextResponse.json({ error: 'Invalid origin / CSRF rejection' }, { status: 403 });
- }
-
- const res = NextResponse.json({ success: true, message: 'Logged out successfully' });
- res.cookies.set(SESSION_COOKIE_NAME, '', {
- maxAge: 0,
- httpOnly: true,
- secure: process.env.NODE_ENV === 'production',
- path: '/',
- sameSite: 'lax',
- });
- return res;
-}
-
-/**
- * GET /api/auth/session
- * Returns the currently authenticated user's profile claims.
- */
-export async function GET(req: NextRequest) {
- try {
- const user = await getServerUser(req);
- return NextResponse.json({
- authenticated: Boolean(user),
- user: user || null,
- });
- } catch (error) {
- return NextResponse.json({ authenticated: false, user: null });
- }
-}
diff --git a/src/app/api/try/[toolId]/route.ts b/src/app/api/try/[toolId]/route.ts
index 947f2ad..4964124 100644
--- a/src/app/api/try/[toolId]/route.ts
+++ b/src/app/api/try/[toolId]/route.ts
@@ -6,6 +6,7 @@ import { getToolById, getToolBySlug } from '@/lib/config/loader';
import { getEndpointById } from '@/lib/catalog/loader';
import { checkRateLimits, recordUsage } from '@/lib/api/rateLimiter';
import { checkFileSignature, executeBackendTryIt, isCircuitOpen } from '@/lib/api/requestBuilder';
+import { verifyTurnstileToken } from '@/lib/turnstile';
let _visitorCookieMaxAge: number | null = null;
function getVisitorCookieMaxAge(): number {
@@ -82,6 +83,28 @@ export async function POST(req: NextRequest, { params }: { params: { toolId: str
try {
const formData = await req.formData();
+
+ // Cloudflare Turnstile Bot & Abuse Verification
+ const turnstileToken =
+ (formData.get('cf-turnstile-response') as string | null) ||
+ req.headers.get('cf-turnstile-response');
+
+ const turnstileResult = await verifyTurnstileToken(turnstileToken, ip);
+ if (!turnstileResult.success) {
+ return NextResponse.json(
+ {
+ state: 'failed',
+ error: {
+ code: 'BOT_VERIFICATION_FAILED',
+ message:
+ turnstileResult.message ||
+ 'Cloudflare Turnstile verification failed. Please complete the security check.',
+ retryable: true,
+ },
+ },
+ { status: 403 }
+ );
+ }
// Primary image extraction: check 'image' first, then common aliases
let file = formData.get('image') as File | null;
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 9537d4c..1856111 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -5,8 +5,6 @@ import { getSiteConfig, getAllCategories, getAllTools } from '@/lib/config/loade
import { Navbar } from '@/components/ui/Navbar';
import { Footer } from '@/components/ui/Footer';
import { SmoothScrollProvider } from '@/components/ui/SmoothScrollProvider';
-import { AuthProvider } from '@/lib/firebase/AuthContext';
-import { AuthModal } from '@/components/auth/AuthModal';
const poppinsFont = Poppins({
subsets: ['latin'],
@@ -178,18 +176,15 @@ export default function RootLayout({
-
- Skip to main content
-
- {children}
-
-
-
+ Skip to main content
+
+ {children}
+