Homework
Homework — build, deploy, inspect the key
Homework — build, deploy, inspect the key.
- Environment. Create
vite.config.ts,.env.exampleand.env(with your NASA key). Type the var insrc/vite-env.d.ts. The app should load the menu viaimport.meta.env.VITE_NASA_API_KEY. - Build.
npm run build. Make suretscruns first (a type error must stop the build). Get adist/. - Find the key in the bundle.
grep -r "DEMO_KEY" dist/assets/. Find it in plaintext. This is the crucial moment: see with your own eyes that a front-end key is public. - Deploy. Upload
dist/to a static host (GitHub Pages / Netlify / Railway). SetVITE_NASA_API_KEYin the host's dashboard and rebuild. - Understand the line. Write 3–4 sentences: why NASA's key can live in the front-end but a payment secret can't, and where the latter should live.
Required tests:
- Build test: a type error stops
npm run build. - Key test:
grepfinds the key in thedist/bundle.
To submit: screenshots: (1) a successful build → dist/, (2) the grep result with the key in the bundle, (3) the deployed app working (a URL).
Next. The app is live on the internet. In lesson 20 — the capstone: extension challenges and closing the arc. You built the same app twice and watched the compiler find real bugs in working code. That IS the course.