All jobs / Frontend / web developer / Tooling
Frontend / web developer interview question · 1–3 years
You need an API base URL in a Vite app without leaking a private key. What do you do?
The strongest answer
Expose only public values via import.meta.env.VITE_* ; keep secrets on the server
Why it works
Anything with the Vite public prefix is in the browser bundle. Base URLs yes; private keys no.
What a good answer covers
- Client env is public.
- VITE_* only for non-secrets (public API URL).
- Secrets stay on the server.
- Don't commit private keys.
Answers that fall short
- Close, but not the strongest: Put the secret in .env and prefix it VITE_ so the client can import it
VITE_ is the leak, not the protection. - Weak: Hardcode localhost and forget production
Hardcoded localhost fails the first deploy. - Red flag: Commit cloud private keys in .env.production
Keys in git are a rotation event.
Who gets asked this
More Tooling questions
- Fast Refresh resets a component's state on every edit. What usually caused it?
- A half-rolled feature is erroring in production. Strongest frontend move?
- What does a bundler such as Webpack or Vite’s production build actually do for you, and what breaks tree…
- Three product teams ship the same header with three bugs. How do you organize frontend platform work?
- A critical vulnerability is published in a package three levels down your dependency tree. The scanner is red…
- Shared packages in a monorepo keep causing diamond-dependency breaks. What do you enforce?
- How do you run a frontend hiring loop that predicts the work, not trivia?
- A bad deploy blanks checkout in one browser. What is the incident response?