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
- It sits in the
public/folder. Vite (the build tool behind Lovable'sVITE_variables and many Bolt web projects) serves files inpublic/at the root of your site and copies them "to the root of the dist directory as-is". Vite's dev server blocks.envand.gitfiles by default, but its docs say that blocklist "does not apply to the public directory". We checked with Vite 8.3.8 on Nov 25, 2026:public/.envcame out asdist/.env, while the.envin the project root was not copied. Next.js serves itspublicfolder from/the same way. - The whole project folder was uploaded. Copy the project to a server or storage bucket as the website and
.envand the hidden.gitfolder go with it. On a VPS, the usual cause is a web server pointed at the project root instead of the build folder. - The deploy tool uploaded more than you thought. Netlify deploys only the publish directory ("Files and assets located outside of the publish directory won't be included"), so check that it is your build folder (
dist), not the repo root. The Vercel CLI skips.git,.env.localand.env.*.localby default, but that list does not include a plain.envor.env.production; use.vercelignorefor anything else you don't want uploaded.
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:
/.env,/.env.local,/.env.production,/.env.development/.git/HEADand/.git/config
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 back | What it means |
|---|---|
| 404 or 403 | Not served at that path. Good. |
| 200 with your homepage HTML | Your 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 lines | Your .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 302 | Usually 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
- 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? - Take the file out of what gets served. Delete
.envfiles and any.gitfolder frompublic/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 aVITE_orNEXT_PUBLIC_prefix. - 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/HEADand/.git/configreturned 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. - Tidy up Git. Git's docs say a
.gitignoredoes not affect files Git already tracks; rungit 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". - 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
- Paths:
/.env,/.env.local,/.env.productionand/.env.development, then/.git/HEADand/.git/config, with plain GET requests that do not follow redirects. It stops at the first.envit finds. It does not request other names such as.env.backupor other files inside.git. - No false alarm on the SPA fallback: a
.envis reported only when the answer is a 200 that is not an HTML page and has aNAME=line;.gitonly whenHEADlooks like a Git ref or commit hash, orconfighas a[core]section. - What it keeps: for a public
.env, only the variable names (up to 12), never the values. A public.envis reported as critical and a public.gitas high, each with a fix prompt for your AI coding tool. - When: both the free check (no sign-up, up to 3 free checks per site per hour) and the deep scan run it. Starter ($19/month, 3 apps) and Pro ($39/month, 10 apps) deep-scan every day and after every deploy that calls your deploy hook, and email only when something is new, worse or fixed, so a later build that copies a
.envintopublic/shows up without you remembering to re-check. Other tools also scan after deploys; see security scanners for vibe-coded apps compared. - In CI: the free LatchDog check script exits non-zero on findings at or above
--fail-on, which defaults to high, so a public.envor.gitfails the build with the default setting.
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
- Vite: Static asset handling (the public directory), server.fs.deny and env variables and modes, read Nov 25, 2026; our own build test with Vite 8.3.8 the same day.
- Next.js: public folder.
- Netlify: build configuration (only the publish directory is deployed). Vercel: ignored files and folders and .vercelignore. Cloudflare Pages: serving pages (single-page app fallback).
- Lovable: Secrets vs VITE_ environment variables.
- Git: gitignore. GitHub: removing sensitive data from a repository. git-dumper.
- nginx: location; snippet tested with nginx 1.26.3 on Nov 25, 2026.
- LatchDog claims checked against our live pricing and how LatchDog scans pages and the scanner code in this project.
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.