Configuration Across Two Deployables — Concept Check
Questions on Configuration Across Two Deployables. Two apps, two sets of variables, and one hard rule: anything the browser can read is public forever, because it is compiled into the bundle.
Questions in this quiz
8 questions on Configuration Across Two Deployables — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You have a frontend application using environment variables prefixed with NEXT_PUBLIC_. What happens if you mistakenly include a secret key in this configuration?
- AThe secret key remains secure as it is only accessible during build time.
- BThe secret key is exposed in the JavaScript bundle and can be accessed by anyone.
- CThe secret key will cause the build process to fail, preventing exposure.
- DThe secret key will be encrypted and not accessible to the public.
2.A developer notices that a frontend variable change requires a rebuild while a backend variable change only requires a restart. Why is this the case?
- ABackend variables are compiled into the code, requiring only a restart.
- BFrontend variables are substituted at build time, while backend variables are read at runtime.
- CFrontend variables are more secure, requiring a rebuild for changes.
- DFrontend variables are stored in a database, needing a rebuild for updates.
3.An engineer accidentally commits a .env.local file containing sensitive information. What should be their immediate action?
- ADelete the commit from the repository history to remove the secrets.
- BRecommit the file with the secrets removed to fix the issue.
- CRotate the leaked secrets immediately, as they are already exposed.
- DIgnore it, as the secrets are not accessible without the server.
4.Why might a missing JWT_SECRET in a backend application cause issues hours after deployment?
- AThe missing JWT_SECRET causes immediate build-time validation failures.
- BJWT_SECRET is not used until a specific scheduled task runs, delaying error detection.
- CThe application crashes on boot if JWT_SECRET is missing, preventing deployment.
- DThe missing JWT_SECRET only becomes apparent when a user tries to log in, causing runtime errors.
5.A developer uses a server-only variable in a client component. What is the expected outcome?
- AThe variable is exposed to the public, causing a security issue.
- BThe application build fails, preventing deployment.
- CThe variable causes a runtime error, crashing the application.
- DThe variable returns undefined in the browser, as designed.
6.What is the purpose of marking a module with 'server-only' in Next.js?
- ATo ensure it is not accidentally imported into a client component, preventing secret exposure.
- BTo optimize server-side performance by caching the module.
- CTo allow the module to be used in both server and client components.
- DTo enable automatic deployment of the module to server environments.
7.Why is it important to validate environment variables at startup in both frontend and backend applications?
- ATo improve application performance by reducing variable access time.
- BTo catch missing or malformed variables early, preventing runtime errors.
- CTo allow variable changes without requiring a rebuild or restart.
- DTo ensure all variables are encrypted before use.
8.A developer commits an .env.example file with real values instead of placeholders. What should they do to correct this?
- AEncrypt the .env.example file to protect the real values.
- BReplace real values with placeholders and ensure the file is committed correctly.
- CDelete the file from the repository to prevent exposure of sensitive data.
- DLeave the file as is, since it is meant for onboarding purposes.