Repository navigation
frontend: avoid unnecessary dev-server bridge calls in production - #4627
thisconnect wants to merge 1 commit into
Conversation
|
@coderabbitai review |
Action performed
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| export const useDevServers = () => { | ||
| const isDevServers = useDefault( | ||
| useLoad( | ||
| import.meta.env.PROD |
There was a problem hiding this comment.
When running make webserve alongside make servewallet-mainnet, Bitrefill and BTC Direct widgets fail to initialize (because PROD=true but Go still defaults to devservers=true).
There was a problem hiding this comment.
Correct, frontend and backend need to run in same mode.
So for make webserve you'll need to run the backend in prod mode with make servewallet-prodservers or make servewallet-mainnet-prodservers. With this Pocket, BTCDirect and Bitrefill iframes load, howerver Moonpay still refuses to connect but for a different reason (also on master I beleive it needs some referrer headers or similar).
There was a problem hiding this comment.
This came up in a codex review as a regression, probably because the requirement to match front and backend is not really documented anywhere? Previously the frontend followed the backend’s flag regardless of build mode, so this requirement wasn’t obvious imo.
There was a problem hiding this comment.
Should I add something to the readme?
for example:
Run the UI in production mode
Run make webserve to build and serve the production version of the UI in a web browser.
This is useful for testing production-specific behavior without building the native app.
In a separate terminal, run make servewallet-prodservers (testnet) or
make servewallet-mainnet-prodservers (mainnet) to start the backend using production servers.
Unlike make webdev, changes to the frontend code are not automatically rebuilt.
Dev servers are only used during development, so querying the go backend for their status in production is unnecessary. Use Vite's build-time environment flag to return false in production, allowing the bundler to eliminate the dev-server bridge call entirely. This avoids unnecessary communication between the frontend and go backend while preserving the existing behavior in development.
9c41c06 to
9773178
Compare
|
rebased |
Dev servers are only used during development, so querying the go backend for their status in production is unnecessary.
Use Vite's build-time environment flag to return false in production, allowing the bundler to eliminate the dev-server bridge call entirely. This avoids unnecessary communication between the frontend and go backend while preserving the existing behavior in development.
Before asking for reviews, here is a check list of the most common things you might need to consider: