Skip to content

Add devMode for NAC widgets#969

Open
rchlfryn wants to merge 5 commits intomainfrom
nac-dev
Open

Add devMode for NAC widgets#969
rchlfryn wants to merge 5 commits intomainfrom
nac-dev

Conversation

@rchlfryn
Copy link
Collaborator

@rchlfryn rchlfryn commented Mar 4, 2026

Summary

  • Add NAC_WIDGET_DEV_MODE environment variable to control the devMode value passed to NAC widget configs
  • When set to "true", overrides the production lock that currently forces devMode to false
  • Falls back to the nacWidgetsConfig global's devMode field when the env var is not set
  • Enables dedicated staging environments to point widgets at the staging base URL without code changes or redeployment

Motivation

Fixes #717

Currently, devMode is always forced to false in production (getNACWidgetsConfig.ts), regardless of the admin panel setting. This makes it impossible to run a staging/preview deployment that uses the NAC staging widget URLs — useful for nwacus/app (AvyApp) development and testing custom data entered in staging.

Changes

  • src/utilities/getNACWidgetsConfig.ts — Check NAC_WIDGET_DEV_MODE env var before falling back to the global config value. Remove the blanket production override so staging deployments can opt in.
  • .env.example — Document the new NAC_WIDGET_DEV_MODE variable.

How it works

Priority order for devMode:

  1. NAC_WIDGET_DEV_MODE env var ("true"true, "false"false)
  2. nacWidgetsConfig.devMode global value from admin panel
  3. Defaults to false

Test plan

  • Verify widgets load normally in local dev with no env var set (devMode respects admin panel)
  • Set NAC_WIDGET_DEV_MODE=true and confirm widgets use the staging base URL
  • Set NAC_WIDGET_DEV_MODE=false and confirm it overrides an admin panel devMode: true
  • Verify production deployment without the env var still defaults to devMode: false
  • Check /api/[center]/nac-config endpoint returns the correct devMode value

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Migration Safety Check

Found 1 potential issue:

20260304_201458_add_dev_mode.ts

Warning (line 6): ALTER keyword detected - review for data loss

sql`ALTER TABLE \`nac_widgets_config\` ADD \`dev_mode\` integer DEFAULT false NOT NULL;`,

Review these patterns and add backup/restore logic if needed. See docs/migration-safety.md for guidance.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Preview deployment: https://nac-dev.preview.avy-fx.org

@rchlfryn
Copy link
Collaborator Author

rchlfryn commented Mar 5, 2026

@busbyk Leaving this as a draft. It is ready fro review but I am curious if you think this is the correct approach based on the issue you wrote.

@rchlfryn rchlfryn marked this pull request as ready for review March 10, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NAC Widgets devMode

1 participant