feat: proxy the BFF to Vite for single-origin HMR in one terminal window - #99
Open
marekdano wants to merge 1 commit into
Open
feat: proxy the BFF to Vite for single-origin HMR in one terminal window#99marekdano wants to merge 1 commit into
marekdano wants to merge 1 commit into
Conversation
Signed-off-by: Marek Dano <mk.dano@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The BFF and frontend used to each need their own terminal (
npm run dev in server/, npm run devat root).npm run dev:allnow starts both together with one command — down to a single terminal for those two, with the API inmcp-context-forgeremaining the only other one needed.build:watch, no HMR) or visiting Vite's dev server directly on:5173— which needs a separate
/api/*route to the BFF and 403s on login/SSE/password-reset unlessPUBLIC_ORIGINis manually overridden to work around the BFF's origin-guard.VITE_DEV_SERVER_URLis set, via a newvite-dev-proxyplugin (@fastify/http-proxy) registered in place of the static-file plugin./api/*,/auth/*,/healthz, and the auth-aware/redirect stay BFF-owned and unaffected — verified via manual route-precedence checks.:3000), matching how the app is served in production, so there's no origin mismatch to configure around.npm run dev:bffandnpm run dev:all(viaconcurrently) to start the BFF (withVITE_DEV_SERVER_URLset) and the Vite dev server together in one command.predev/predev:bff/predev:allnpm lifecycle hooks that checknode_modulesis in sync beforedev/dev:bff/dev:allrun, so a missing install fails with a clear "run npm install" message instead of a barecommand not found.predev:allalso runsnpm run generatebefore starting either dev server, sodev:allalways has freshsrc/generated/types — both on a fresh clone (that directory is gitignored and 34 files import from it) and after editingopenapi.jsonmid-session..env.exampleto document the new flow, alongside the existingbuild/build:watchpath for testing the exact BFF-served bundle.Test plan
npm run build— succeedsnpm run lint(inserver/) — typechecks cleannpm run dev:allfrom repo root:http://localhost:3000/loads, redirects to/app/loginwhen unauthed, HMR client/React-refresh correctly injected into/app/curl http://localhost:3000/healthzand/api/*still return BFF responses (not proxied to Vite)node_modules—dev,dev:bff, anddev:alleach fail with the intended message instead ofcommand not foundsrc/generated/—dev:allregenerates it viapredev:allbefore either dev server starts