Skip to content

fix: write a valid care_fe/.env.local so the frontend dev server starts - #2

Merged
khavinshankar merged 1 commit into
ohcnetwork:mainfrom
amjithtitus09:fix/care-fe-env-local
Sep 11, 2026
Merged

fix: write a valid care_fe/.env.local so the frontend dev server starts#2
khavinshankar merged 1 commit into
ohcnetwork:mainfrom
amjithtitus09:fix/care-fe-env-local

Conversation

@amjithtitus09

Copy link
Copy Markdown
Member

Problem

After care create, care run can't bring up the frontend:

  1. care_fe's dev server fails env validation. create copied care_fe's .example.env into care_fe/.env.local. That template leaves most keys blank (REACT_GITHUB_URL=, REACT_MAIN_LOGO=, …). Vite loads them as "", and care_fe's scripts/validate-env.ts rejects them because zod's .optional() only accepts a missing key. Vite aborts with 17 validation errors.
  2. With the ABDM frontend plug selected, the app would crash on load. REACT_ENABLED_APPS was written as care_abdm_fe@localhost:5173. care_fe's care.config.ts expects org/repo@host/path/to/remoteEntry.js and throws Invalid plug configuration: care_abdm_fe. Expected 'org/repo@url'. while the module loads. Adding just the org isn't enough: care_fe merges this entry's URL over the plugin config the CLI registers in the backend, and @localhost:5173 resolves to http://localhost:5173/ instead of remoteEntry.js.

Changes

  • create writes only the CLI's own keys to care_fe/.env.local (REACT_CARE_API_URL, REACT_ENABLED_APPS, plus any plug env) and no longer copies .example.env. The defaults already come from care_fe/.env, and care_fe's README only asks for REACT_CARE_API_URL in .env.local.
  • A new remoteEntryUrl() helper supplies the URL for both the registered plugin config and REACT_ENABLED_APPS, which is now org/repo@host/assets/remoteEntry.js.
  • plugs.json: enabledApp for care_abdm_fe is now 10bedicu/care_abdm_fe. types.ts documents the org/repo format.

Testing

  • npm run typecheck and npm run build pass. The built dist/cli.js no longer references .example.env.
  • Ran create --skip-install against a scratch setup that had care_fe's real .example.env in place (Docker runtime, care_abdm_fe selected). The generated care_fe/.env.local is exactly:
    REACT_CARE_API_URL=http://127.0.0.1:9000
    REACT_ENABLED_APPS=10bedicu/care_abdm_fe@localhost:5173/assets/remoteEntry.js
    
  • With that file, care_fe (develop) starts, the landing page renders, and the ABDM plugin's remoteEntry.js and manifest load from :5173.
  • Ran care_fe's careApps parsing from care.config.ts on three values. The old value throws, org-only gives http://localhost:5173/, and the new value gives the remoteEntry.js URL.
  • Not done: a clean-slate createrun from the packed tarball in an empty directory.

Notes for reviewers

  • Setups created with 0.2.0 or 0.2.1 aren't repaired by this PR. Re-running create only rewrites the CLI's own keys, so the blank template lines stay. Workaround: delete care_fe/.env.local, then re-run care create --skip-install. A follow-up could have create drop blank KEY= lines from an existing file.
  • The completion message still says cd <dir> && care run. That doesn't work after npx @ohcn/care create, because npx doesn't put care on the PATH. Those users need npx @ohcn/care run <dir>. This is also left for a follow-up.

`care run` could not start care_fe. `create` copied care_fe's .example.env into
.env.local, and its blank `KEY=` placeholders load as "" and fail care_fe's env
validation (zod `.optional()` only accepts a missing key), so Vite aborted with
17 errors. .env.local now holds only the CLI's overrides; care_fe/.env already
supplies the defaults.

REACT_ENABLED_APPS was written as `care_abdm_fe@localhost:5173`. care_fe parses
entries as `org/repo@host/path/to/remoteEntry.js` and throws on a bare repo name
while loading care.config.ts, which blanks the app. The entry's URL also
overrides the plugin config registered in the backend. The registry now uses
`10bedicu/care_abdm_fe`, and the entry points at the same remoteEntry.js URL as
the plugin config.
@khavinshankar
khavinshankar merged commit ddddc71 into ohcnetwork:main Sep 11, 2026
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.

2 participants