VibeCodeHealth

discord

Discord and Slack webhooks in your Lovable app are public passwords—fix them

Why a discord.com/api/webhooks or hooks.slack.com URL in frontend code is a full secret, how to check in two minutes, and copy-paste Next.js and Supabase Edge proxy patterns—then re-scan with the free grader.

Paste your production URL into the free Vibe Code Health grader for a Semrush-style score on secrets, headers, TLS, and common leaks—then come back to this guide for the fixes.

You asked Lovable, Bolt, or v0 for a “contact form that pings Discord” or “Slack me when someone signs up.” The AI pasted a long https://discord.com/api/webhooks/… (or https://hooks.slack.com/services/…) URL straight into a React file. The form worked. You shipped.

Here is the catch: that webhook URL is a password. Anyone who can view your page source, download your JavaScript bundle, or open DevTools can copy it and post into your channel forever—spam, phishing links, fake “payment received” messages—until you delete the webhook.

This guide is only about Discord and Slack incoming webhooks leaked in vibe-coded frontends (and a short note on Stripe’s whsec_ signing secret). It is not a general API-key tour (API keys in frontend code) and not a Supabase key explainer (Supabase keys).

Scan your live URL with Vibe Code Health—a public Discord or Slack webhook forces an F, same as a live Stripe secret.

What a webhook URL actually is

Discord’s docs say an incoming webhook is a unique URL you POST JSON to in order to send a message to a channel (Discord: Webhook Resource). Slack’s incoming webhooks work the same way: a special URL that posts into a channel you chose (Slack: Sending messages using incoming webhooks).

There is no separate “API key” field next to the URL for these simple integrations. Possession of the URL is authorization. Discord even documents regenerating the token portion of the URL when it leaks (Discord: Edit Webhook).

That is why stuffing the URL into App.tsx is equivalent to committing a bot token to GitHub—except the browser makes the leak automatic for every visitor.

Why vibe builders do this by default

AI app builders optimize for a working demo in one chat turn:

  1. You paste a webhook from Discord Server Settings → Integrations.
  2. The model writes fetch(webhookUrl, { method: "POST", body: … }) in a client component.
  3. Vite / Next inlines the string into the public JS bundle (VITE_DISCORD_WEBHOOK, NEXT_PUBLIC_SLACK_HOOK, or a hard-coded constant).
  4. Launch boards and scrapers pull the hostname; automated scanners harvest webhook patterns the same way they harvest sk_live_.

Minification does not help. The full URL still appears as a string literal in the bundle.

The anti-pattern (looks fine, is not)

// ❌ Dangerous — ships to every visitor's browser
const DISCORD_WEBHOOK =
  "https://discord.com/api/webhooks/123456789012345678/AbCdEf…";

async function onSubmit(message: string) {
  await fetch(DISCORD_WEBHOOK, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ content: message }),
  });
}

Same idea with Slack:

// ❌ Also a public password
await fetch("https://hooks.slack.com/services/T…/B…/…", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: message }),
});

Two-minute check (before or after launch)

  1. Open your production site.
  2. DevTools → Network → submit the form once → look for requests to discord.com or hooks.slack.com from the browser.
  3. Or DevTools → Sources / search-in-all-files for api/webhooks or hooks.slack.com.
  4. Paste the URL into Vibe Code Health. A finding titled Discord webhook URL is public or Slack incoming webhook URL is public means the secret is already downloadable.

If you find one: treat it as burned. Do not “hide” it behind an env var that still starts with VITE_ or NEXT_PUBLIC_—those prefixes exist specifically to embed values in the client.

Fix: browser → your backend → Discord/Slack

The safe shape is identical to other secret vendors:

  1. Rotate the webhook (Discord: delete or regenerate under Server Settings → Integrations → Webhooks; Slack: remove the incoming webhook and create a new one).
  2. Store the new URL as a server-only secret (DISCORD_WEBHOOK_URL / SLACK_WEBHOOK_URL—no public prefix).
  3. Expose a small API route or edge function that your form calls.
  4. Add boring defenses on that route: authentication if the form is for signed-in users, rate limiting, length limits, and basic content filtering so random people cannot turn your function into a spam relay.

Next.js (App Router) example

// app/api/notify/route.ts — server only
export async function POST(req: Request) {
  const { message } = await req.json();
  const text = String(message ?? "").trim().slice(0, 1800);
  if (!text) {
    return Response.json({ error: "Empty message" }, { status: 400 });
  }

  const webhook = process.env.DISCORD_WEBHOOK_URL;
  if (!webhook) {
    return Response.json({ error: "Not configured" }, { status: 500 });
  }

  // TODO: rate-limit by IP or session before this fetch
  const res = await fetch(webhook, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ content: text }),
  });

  if (!res.ok) {
    return Response.json({ error: "Upstream failed" }, { status: 502 });
  }
  return Response.json({ ok: true });
}
// ✅ Client — no webhook string anywhere
await fetch("/api/notify", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ message: formValue }),
});

On Vercel, set DISCORD_WEBHOOK_URL in Project → Settings → Environment Variables and leave “Sensitive” / non-public. Never check the “expose to browser” box in Lovable, Bolt, or v0.

Supabase Edge Function (common with Lovable + Supabase)

import "jsr:@supabase/functions-js/edge-runtime.d.ts";

Deno.serve(async (req) => {
  const { message } = await req.json();
  const webhook = Deno.env.get("DISCORD_WEBHOOK_URL");
  if (!webhook) return new Response("missing secret", { status: 500 });

  await fetch(webhook, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      content: String(message).slice(0, 1800),
    }),
  });
  return Response.json({ ok: true });
});

Store the secret with supabase secrets set, not in the Vite env file. Call the function from the browser with your project’s anon key only if you also add auth or a captcha—otherwise strangers can still spam through your function (better than owning your Discord channel directly, but still worth rate-limiting).

Lovable / Bolt / v0 checklist

  1. Delete the hardcoded webhook from chat history files and any “public” env toggles.
  2. Add a backend/cloud function the builder supports (or export to GitHub and add a Vercel/Netlify/Supabase function).
  3. Put the new webhook only in private secrets.
  4. Redeploy, confirm Network tab no longer shows discord.com / hooks.slack.com from the client.
  5. Re-scan on Vibe Code Health and open related beginner notes on /learn.

Stripe’s cousin: whsec_ signing secrets

If your AI also added Stripe Checkout, watch for whsec_… in frontend code. That value is the webhook signing secret Stripe uses so your server can verify events with constructEvent (Stripe: Verify webhook signatures). It belongs only on the server route that receives POST from Stripe—not in the browser, and not next to pk_live_ in a shared .env that Vite bundles.

Rotate it under Stripe Dashboard → Developers → Webhooks → your endpoint if it ever shipped publicly. Publishable keys (pk_) stay in the client; sk_ and whsec_ do not (Stripe: API keys).

What “fixed” looks like

SignalStill brokenFixed
Bundle search for api/webhooksHitNo hit
Network on form submitBrowser → Discord/SlackBrowser → your /api/… only
Env nameVITE_DISCORD_WEBHOOKDISCORD_WEBHOOK_URL (server)
Vibe Code Health gradeF on webhook findingFinding gone after redeploy

Keep going

Rotate first, proxy second, then re-scan. A contact form that quietly publishes a Discord webhook is one of the easiest “it works on my machine” security failures in vibe coding—and one of the fastest to fix once you know the URL is the key.

Grade your app next

Passive scan only—no login, no crawl of your whole site.

Open the scanner

Platform checkers

Free A–F grades written for the host you ship on.