Bird
0
0

You want to safely use a public API key in your Remix app's client code and keep a secret key only on the server. Which approach correctly manages environment variables?

hard📝 Application Q15 of 15
Remix - Deployment
You want to safely use a public API key in your Remix app's client code and keep a secret key only on the server. Which approach correctly manages environment variables?
APrefix public keys with <code>PUBLIC_</code> and access them in client code; keep secrets without prefix and access only in server code
BStore all keys in <code>process.env</code> and access them directly in client code
CPut all keys in a JSON file and import it in both client and server code
DUse <code>window.env</code> to store keys and access anywhere
Step-by-Step Solution
Solution:
  1. Step 1: Understand Remix environment variable conventions

    Remix exposes environment variables prefixed with PUBLIC_ to client code safely; secrets remain server-only.
  2. Step 2: Evaluate options for security and access

    Prefix public keys with PUBLIC_ and access them in client code; keep secrets without prefix and access only in server code follows this pattern, separating public and secret keys correctly. Others expose secrets or use insecure methods.
  3. Final Answer:

    Prefix public keys with PUBLIC_ and access them in client code; keep secrets without prefix and access only in server code -> Option A
  4. Quick Check:

    Use PUBLIC_ prefix for client env vars [OK]
Quick Trick: Prefix public env vars with PUBLIC_ for safe client use [OK]
Common Mistakes:
MISTAKES
  • Exposing all keys to client without prefix
  • Storing secrets in JSON files accessible to client
  • Using window.env which is not standard

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes