Skip to content

Conversation

@Vinnl
Copy link
Collaborator

@Vinnl Vinnl commented Dec 1, 2025

References:

Jira: MNTOR-5089
Figma:

Description

This is a proposal for how to centralise our environment-specific configuration. If you both agree with this approach, I can do a sweep over the codebase for all references to process.env, and replace them by references to config.

One other thing we might consider is adopting @next/env instead of dotenv-flow - behaviour should be the same I think, but then we're using the exact same code Next.js is using to load env vars, so that's technically one fewer dependency, and less risk of divergence. (Plus, I'm not sure if dotenv-flow is being very actively maintained, and we need a fix there for the Next.js upgrade.)

How to test

I've included two examples where config are used:

  • On /admin/dev. To verify that this works, access that page with an admin account locally, then run using e.g. APP_ENV="production" npm run dev or by setting that in your .env.local, and verify that you now get a 404 on that page with the same account.
  • To verify that it also works in non-Next.js environments, I also added it to npm run dev:cron:monthly-activity-free. Likewise, if you set MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE to a value other than 10, you should see that referenced in the logs:
{"level":"info","message":"Getting free subscribers with batch size: 10"}

Checklist (Definition of Done)

  • Localization strings (if needed) have been added.
  • Commits in this PR are minimal and have descriptive commit messages.
  • I've added or updated the relevant sections in readme and/or code comments
  • I've added a unit test to test for potential regressions of this bug.
  • If this PR implements a feature flag or experimentation, I've checked that it still works with the flag both on, and with the flag off.
  • If this PR implements a feature flag or experimentation, the Ship Behind Feature Flag status in Jira has been set
  • Product Owner accepted the User Story (demo of functionality completed) or waived the privilege.
  • All acceptance criteria are met.
  • Jira ticket has been updated (if needed) to match changes made during the development process.
  • Jira ticket has been updated (if needed) with suggestions for QA when this PR is deployed to stage.

@Vinnl Vinnl requested review from codemist and kschelonka December 1, 2025 14:32
@Vinnl Vinnl self-assigned this Dec 1, 2025
@Vinnl Vinnl added 🛑 Do Not Merge Do not merge this PR, even if approved. Review: XS Code review time: up to 30min labels Dec 1, 2025
Copy link
Collaborator

@codemist codemist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I had a question I left in the Jira ticket about where the env differences are. Also, is it possible to update the rest of the codebase once we've completed code removal?

@Vinnl
Copy link
Collaborator Author

Vinnl commented Dec 2, 2025

Thanks @codemist. I'll probably start work on updating the rest to have something to work on, but I'll make sure not to merge it before your work, since conflicts are probably way easier for me to resolve (since my changes will basically all be the same change).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review: XS Code review time: up to 30min 🛑 Do Not Merge Do not merge this PR, even if approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants