
In the last post, you probably wrote "API keys go in .env" into your AGENTS.md. Today we'll look at why that line matters, and what you need to check before publishing an app. And then, finally, your project gets an address on the internet.
The order matters: draw the line first, then ship.
1. An app can work while leaving its data exposed
You ask an AI to build an app, try it yourself, and everything looks fine. But a working screen doesn't tell you whether someone else can read the database without permission.
That's the part that worries me: you can publish an app without realizing what it exposes. "It feels fine" isn't enough. You need to check who can access the data and where the secrets end up. Here are three rules I use.
2. Rule 1: keys go in .env, and .env goes in .gitignore
Remember? In part 1, I said files starting with a dot are hidden, and in part 2 we put .env into .gitignore ahead of time. Today that pays off.
# .env: where the real secrets live
API_KEY=sk-your-real-key
# .gitignore: the line we added back in part 2
.env
An API key is both a password and a credit card. If it leaks, someone else spends your money. So work with a fake value during development and put the real key in yourself at the very end. And never paste a real key into an AI prompt.
My feed used to show joke reels about "quitting and taking the company down with you," where the punchline was a departing employee adding .env to Git and pushing it. That's how dangerous it is.
3. Rule 2: never put secret keys in the frontend
This is something I demonstrate live in class, and you can try it right now. Open any website and press F12. The developer tools open, and under the Sources tab you can see all of the site's frontend code.
Secret keys belong on the server (the backend). Some services also provide public client keys, designed to appear in browser code; those still need access controls on the data they can reach. In terms of the web's three layers:
- Browser (frontend): what you see. Put a secret key here and everyone sees it.
- Server (backend): what does the work. Secret keys belong here.
- Database: what remembers. It needs a lock.
4. Rule 3: turn on the database's lock
With services like Supabase, check the permissions on every table exposed through the API. Enable row-level security (RLS) and define who may read or change each row. A public client key is not a substitute for those rules.
So the moment you connect a database, put this in your prompt:
Connect Supabase, and create RLS policies along with it.
Anyone who isn't logged in must not be able to read any data.
Then check it yourself. After deploying, open the site while logged out (or in a private window) and check whether protected data can be fetched. Also test that one signed-in user cannot read another user's private records. Hiding a screen alone doesn't protect the API. It's the security version of part 3's "don't trust 'Done!'"
5. Personal data: a line in three levels
This area needs judgment rather than a rule, so I sort data into three levels:
- 🟢 Practice data: made-up people and records, with labels like "User A" or "Team 2." Use these while building.
- 🟡 Caution: real names combined with things like work patterns. Only on your own computer or inside your organization; never deployed publicly.
- 🔴 Off-limits: contact details, national ID numbers, medical information. Don't build it with AI alone; get an expert to review it.
Say you're building a shift-schedule program for a hospital. That isn't just a table; it's HR data combining real names, departments, and work patterns. Use made-up people while developing it. Replacing a real person's name with an alias doesn't necessarily make the underlying schedule anonymous.
I'm firm about this one. If something goes wrong, you can't say "the AI built it." The person who built it is responsible.
Start the pre-deployment check with these commands:
git status # review pending changes
git ls-files -- .env ".env.*" # check for tracked environment files
git diff --cached # inspect exactly what will be committed
# Review tracked files for secrets, and test access while logged out.
These are starting checks, not proof that no secret exists: keys can use many formats, and a clean Git status can still include tracked secrets. Keep real secrets out of tracked files; a committed .env.example should contain placeholders only.
Already committed .env? Revoke the key and issue a new one before you worry about rewriting history. A key that's been published can't be taken back.
6. Now we deploy
The line is drawn, so it's time to ship. Deployment is simple to describe:
- Local:
localhost:8501. Only you can see it, and it stops when you turn your computer off. - Deployed:
https://your-name.github.io. Anyone can see it, and it keeps running when your computer is off.
The nice thing is that you already have every ingredient:
- A GitHub repository: from part 2.
requirements.txt: written out in part 1.- Environment variables (secrets): the keys from today.
Where to deploy depends on whether your project is static or dynamic:
- Static (files shown as they are): a single HTML page, an about page → GitHub Pages or Vercel. Very easy.
- Dynamic (a server has to do work): a Python app, a service with login → Streamlit Community Cloud, Railway, or Render.
Static deployment really is easy. Push index.html to the root of your GitHub repository, open Settings → Pages, select Deploy from a branch, choose main and /(root), and save. Once the deployment finishes, visit https://your-id.github.io/repository-name/ and you're live 🎉
Dynamic deployment has one more step. .env isn't uploaded, so you have to register your keys separately in the platform's secrets settings. Forgetting this is one of the most common reasons a deployment fails.
7. When deployment fails, start with the logs
Your first deployment will almost certainly fail. That's fine; the response is always the same:
When a deployment fails, don't look at the code. Read the logs first.
Find Logs on the platform, copy the log, and remove any keys or personal data before giving it to the AI: "The deployment failed. Read this log and tell me why." The usual suspects are three:
- Missing or incomplete
requirements.txt→ModuleNotFoundError(the one you met in part 1!) - Environment variables not registered → key-related errors
- Typos in file names or paths → file not found
It also helps to know the realities of free tiers. Some services put idle apps to sleep, so a later visit takes time to wake them. Limits vary by platform and plan. Free has its reasons, but it's plenty for a personal project.
I've used Vercel, Streamlit, and Cloudflare myself. For a simple project, I often connect a GitHub repository to Vercel; for a heavier page or a project whose data needs more care, I've also used Cloudflare. That's my workflow, though—the hosting platform doesn't replace checking access controls.
Today's six rules
- Keys in
.env, and.envin.gitignore. An API key is a credit card. - No secret keys in the frontend. Browser code is public.
- When you add a database, turn on its lock (RLS) first, and check while logged out.
- Draw a three-level line for personal data: 🟢 synthetic examples / 🟡 restricted use / 🔴 expert review.
- Static or dynamic decides where you deploy.
- When deployment fails, read the logs first.
Your project now has an address on the internet. Send the link to someone. It's probably the most satisfying moment of the whole class.
You probably repeated the same steps several times while deploying today: check for secrets, update requirements, commit, read the logs... Next time, we turn that repeated procedure into a reusable workflow.
And in the final part, part 1's "never approve a command you don't understand," part 3's plan approval, and part 4's rules file all come together. That's where you'll meet this series' last claim.
Sources
- Supabase, Row Level Security: controlling access to database rows.
- GitHub, Configuring a publishing source for GitHub Pages: the branch and folder settings for a static site.
- Appwrite, vibe coding security best practices: further reading from the Korean post.