Next Env Secret Boundary

    1

    Stop API keys and service-role tokens from leaking into the Next.js browser bundle — audit NEXT_PUBLIC_ misuse and harden server-only boundaries.

    $9

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Next Env Secret Boundary

    Example session with this skill installed

    Audit the Supabase client setup in this Next.js project. I suspect the service role key is leaking into the browser bundle.

    • Read your context and instructions
    • Compiled the next env secret

    I have audited your Supabase configuration and identified a major boundary violation where the service role key is exposed via a public prefix.

    Secret inventory

    NameSourceTypeImporters
    NEXT_PUBLIC_SUPABASE_URL.env.localPubliclib/supabase.ts
    NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY.env.localSECRETlib/supabase.ts, components/AdminPanel.tsx

    Boundary findings

    Blocker: NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY uses a public prefix. Next.js will inline this value into the browser bundle at build time.

    • Major: components/AdminPanel.tsx is a "use client" module importing the admin client directly.
    • Minor: lib/supabase.ts lacks a server-only guard, allowing it to be imported by any client component.

    Hardening patch

    // 1. Rename variable in .env.local to remove public prefix:
    // SUPABASE_SERVICE_ROLE_KEY=your_secret_here
    
    // 2. Create a server-only admin client
    // lib/supabase/admin.ts
    import "server-only";
    import { createClient } from "@supabase/supabase-js";
    
    export function createAdminClient() {
      const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
      const key = process.env.SUPABASE_SERVICE_ROLE_KEY;
      if (!url || !key) throw new Error("missing_supabase_admin_env");
      return createClient(url, key, {
        auth: { persistSession: false, autoRefreshToken: false },
      });
    }
    

    Residual risks

    Rotation: The SERVICE_ROLE_KEY has been exposed to the client. You must rotate this key in the Supabase dashboard immediately.

    • Git History: Check if .env.local was ever committed to version control.
    • CI: Ensure secret scanning is enabled to catch future NEXT_PUBLIC_ secret additions.

    Next steps

    1. Rename the environment variable in your local and production environments.
    2. Replace direct admin client imports in client components with Server Actions.
    3. Run a fresh build to verify the secret is no longer in the JS chunks.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Keep privileged secrets on the server. This Cursor skill audits Next.js / React apps for env boundary bugs: admin keys under NEXT_PUBLIC_*, service-role clients imported by "use client" modules, missing server-only guards, hardcoded tokens, and secrets echoed in client-visible errors. Output every run: Secret inventory → Boundary findings (blocker/major/minor) → Hardening patch → Residual risks (rotation + git history). Fits App Router + TypeScript. Complements Server Action AuthZ and Webhook HMAC Gate without duplicating them. Does not replace cloud key rotation or IAM.

    Requires access to .env files and source code. Does not rotate keys in external vaults or manage Cloud IAM. Cannot guarantee detection if bundle analysis is not possible from source code.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 20 days ago

    Permissions

    Network Access
    Environment Variables
    Read Files
    Write Files
    Listed20 days ago

    What's inside

    Frequently Asked Questions

    This skill performs a deep-tree analysis of your Next.js application to identify sensitive credentials—like database strings or service role keys—that are accidentally exposed to the browser via public prefixes or client-side imports.

    Yes, while optimized for the App Router and 'use client' boundaries, it also identifies leaks in Pages Router projects by auditing the data flow between getServerSideProps and the client-facing component.

    Unlike a generic prompt, this skill follows the full import graph of your project, detecting 'transitive leaks' where a secret is buried inside a shared utility file that is eventually bundled into a React component.

    The skill provides actionable remediation, including code patches to implement 'server-only' guards and refactored module structures to isolate admin SDKs from your UI components.

    This skill is designed to run in any environment that supports file-system access and TypeScript/JavaScript analysis, making it compatible with most developer-focused AI agents and IDE extensions.

    No, this skill focuses strictly on the code and configuration level; it does not access or modify secrets stored in cloud providers like AWS Secrets Manager or Vercel Environment Variables.

    New in Frontend & Web Apps