LatchDog

← Guides

Is my .env file public? How to check a live app for exposed .env and .git files

Short answer: open https://yourapp.com/.env and https://yourapp.com/.git/config on your live site and read what comes back. Lines like STRIPE_SECRET_KEY=... or a [core] section mean the file is public: replace every secret in it first, then take the file out of what your host serves and check again. Your own homepage coming back with a 200 is not a leak; single-page apps answer every unknown path that way.

Disclosure: LatchDog is our product, and its free check requests these paths for you. Everything about Vite, Vercel, Netlify, Cloudflare Pages, Lovable, Git and GitHub below comes from their own docs, read on Nov 25, 2026 and linked under Sources. If their docs now say something different, theirs are right and this page is out of date.

Why bother checking

Bots ask for these files all day. latchdog.com is about a month old and gets very few human visitors, yet our Cloudflare logs show automated requests for /.env variants on most days (on Nov 22, 23 and 24, 2026, for example, alongside /.git/config and /.env.backup). A public .env usually holds the keys that cost money or open your database: Stripe and OpenAI secret keys, a Supabase service_role or sb_secret_ key, a database password. A public .git folder can be worse: public tools such as git-dumper ("A tool to dump a git repository from a website") rebuild a repository from it, including any secret that was ever committed and later deleted.

How a .env file ends up on a live site

Lovable is a special case. Lovable's docs say its .env is meant to be committed (don't add it to .gitignore, or previews break) and should hold only VITE_ values such as VITE_SUPABASE_URL and VITE_SUPABASE_PUBLISHABLE_KEY, which end up in the browser anyway. Private keys such as STRIPE_SECRET_KEY or OPENAI_API_KEY belong in Lovable's Secrets, which its docs say are injected into Edge Functions and never reach the browser. So in a Lovable project the question to ask is less "is .env public?" and more "is there anything secret in it?"

Check your live app in two minutes

Only check sites you own. Use the live address, not the editor preview. In a private browser window, open each of these, or use curl:

for p in .env .env.local \
 .env.production .env.development \
 .git/HEAD .git/config; do
 echo "== /$p"
 curl -so ld-body -w \
  "%{http_code} %{content_type}\n" \
  "https://yourapp.com/$p"
 head -c 200 ld-body; echo
done

That prints each status code and content type, then the first 200 characters of the answer (so run it in your own terminal, not a shared log). Read the body, not just the number:

What comes backWhat it means
404 or 403Not served at that path. Good.
200 with your homepage HTMLYour host's single-page-app fallback, not a leak. Cloudflare Pages, for example, serves your root page for any path that is not a file when there is no top-level 404.html.
200 with NAME=value linesYour .env is public. Go to the fix below.
200 with ref: refs/heads/... or [core]Your .git folder is public. Treat your full history as readable.
301 or 302Usually HTTP to HTTPS. Repeat on the address it points to.

A clean result covers these paths on this one hostname only. It says nothing about a key that was built into your JavaScript through a VITE_ or NEXT_PUBLIC_ variable (see exposed API keys in JavaScript bundles), backup copies with other names such as .env.backup, or an old preview deployment on another URL.

If it's exposed: fix it in this order

  1. Replace every secret that was in the file. Assume it has already been copied; hiding the file does not un-leak a key. For each one, create a new key in the provider's dashboard, switch your server-side code to it, then revoke the old one. GitHub's guide on removing sensitive data says that if the data is a secret, "as a first step you need to revoke and/or rotate that secret". For a Supabase secret key, follow what to do if your service_role key leaked. Public values (a Supabase URL, an anon or publishable key, a Stripe pk_ key) were already in your JavaScript, so they don't need replacing for this; see is the Supabase anon key safe to expose?
  2. Take the file out of what gets served. Delete .env files and any .git folder from public/ and from the build folder, rebuild, and deploy only the build output. Move server-only secrets to your host's environment variables, Supabase Edge Function secrets or Lovable Secrets, never to a variable with a VITE_ or NEXT_PUBLIC_ prefix.
  3. Running your own server? Add a backstop. On nginx, this returns 404 for every path that starts with a dot except /.well-known/ (which HTTPS certificate renewal needs). We tested it with nginx 1.26.3 on Nov 25, 2026: /.env, /.env.local, /.git/HEAD and /.git/config returned 404, and /.well-known/acme-challenge/ files still loaded.
    location ~ /\.(?!well-known/) {
        return 404;
    }
    It is a safety net; the real fix is step 2.
  4. Tidy up Git. Git's docs say a .gitignore does not affect files Git already tracks; run git rm --cached .env, then add the name to .gitignore (not in a Lovable project, per the note above). The old copy stays in your history, which is why step 1 comes first. Once the secret is rotated, GitHub notes that rewriting history "may not be warranted".
  5. Redeploy and check again, then look at each provider's usage or logs for activity you don't recognise from while the old key was live.

What LatchDog checks here, exactly

None of this proves your app is secure. It can't see your code, database rules or the keys in your provider dashboards; the vibe coding security checklist lists what else to check.

Paste-in prompt for your AI coding tool

My live site may be serving a .env file or a
.git folder. Check my project for any .env* file
or .git folder inside public/ or the build output
(dist, out, build), and remove them. Make sure the
deploy publishes only the build folder. List every
secret that was in those files so I can rotate it,
and move each server-only secret to my host's
environment variables or my backend's secrets.
Never use a VITE_ or NEXT_PUBLIC_ prefix for a
secret. Don't change unrelated code.

Check yours

Run the free LatchDog check on your live URL (no sign-up). It requests these paths and also looks for secret keys in your JavaScript and source maps, security headers and HTTPS. LatchDog keeps watching your live app after launch. Starter ($19/month, up to 3 apps) and Pro ($39/month, up to 10 apps) re-scan it automatically every day and after every deploy (triggered by a deploy hook from your host or CI), and email you only when something changes. Nothing to install: you verify your domain once.

Sources

Keep watching your app, not just checking it once

LatchDog keeps watching your live app after launch. Starter ($19/month, up to 3 apps) and Pro ($39/month, up to 10 apps) re-scan it automatically every day and after every deploy (triggered by a deploy hook from your host or CI), and email you only when something changes. Nothing to install: you verify your domain once.

Start with the free check (headers, HTTPS, leaked keys in your JavaScript, source maps, .env/.git). Open-table checks run after you verify your domain. See plans

Free, read-only public check: no sign-up, no card. Headers, HTTPS, leaked keys in your JavaScript (always masked), public source maps and exposed .env/.git files. Supabase table checks run after you verify you own the domain.

Want the open-table check too? Get my free deep scan: sign in with your email (no password) and verify you own the domain. Your first deep scan is free and adds CORS, more of your JavaScript and, if your app uses Supabase, whether anyone can read its tables and views with your public key.