Fix guides

Your .env file is a URL away.

Updated 2026-10-13 · Plain English, written for founders who built with Lovable, Bolt, Cursor or similar.

Your .env file holds every secret your app has: database passwords, Stripe keys, AI keys. If your web server hands it out at https://yourapp.com/.env, anyone can download it. A served .git folder is worse. From it, free tools rebuild your entire source code and its history, including every secret you ever committed and later deleted.

Bots request /.env and /.git/HEAD on new websites all day. This is one of the first things they check.

Check in ten seconds

curl -s https://yourapp.com/.env | head -5
curl -s https://yourapp.com/.env.local | head -5
curl -s https://yourapp.com/.env.production | head -5
curl -s https://yourapp.com/.git/HEAD

While you are there, check source maps. Open one of your JavaScript files in the browser and add .map to the end of the URL. If a file downloads, anyone can read your original source code, comments included. It is not always a disaster, but it makes every other mistake easier to find, and secrets are sometimes inside.

Rotate first

If either file was public, every value in it is compromised. You can't know who fetched it.

Fix the cause

This happens when the web server publishes your whole project folder instead of just the build output. Common causes:

For source maps: Vite and Next.js do not publish them by default, so check whether someone turned them on (build.sourcemap in Vite, productionBrowserSourceMaps in Next.js). If you need them for error tracking, upload them to your error tracker privately instead of serving them.

Stop it happening again

Check your app

SecureIndie looks for this mistake. The free quick check covers the basics from outside (exposed files, keys in your site's code, headers) in about a minute. Database rules, payment webhooks and AI endpoints need the full audit, which also reads your code and proves what a visitor can actually reach.

Questions

My host is Vercel or Netlify. Can this happen to me?

Rarely for /.env, because those builds only publish the output folder. It happens when the output folder is the project root, or when a file gets copied into public/ or dist/.

I got a 200 for /.env but it is my homepage HTML. Is that a leak?

No. Single-page apps answer every path with index.html. It is only a leak if the response contains lines like KEY=value.

Do I have to rotate keys if I fix it quickly?

Yes. You cannot know who fetched it while it was public, and bots check /.env on new sites within hours of them going live.

Related guides

Checks covered: INFRA-EXP-001, INFRA-EXP-002, INFRA-MAP-003, SEC-HIST-003 · If you think data already leaked