Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontends/web/src/contexts/AppProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { AppContext } from './AppContext';
import { useLoad } from '@/hooks/api';
import { useDefault } from '@/hooks/default';
import { getNativeLocale } from '@/api/system';
import { getDevServers, getTesting } from '@/api/environment';
import { getTesting } from '@/api/environment';
import { getOnline, subscribeOnline } from '@/api/network';
import { i18nextFormat } from '@/i18n/utils';
import type { TChartDisplay, TPortfolioPercentageType, TSessionConfig } from './AppContext';
import { useOrientation } from '@/hooks/orientation';
import { useMediaQuery } from '@/hooks/mediaquery';
import { useSync } from '@/hooks/api';
import { useDevServers } from '@/hooks/environment';

type TProps = {
children: ReactNode;
Expand All @@ -27,7 +28,7 @@ export const AppProvider = ({ children }: TProps) => {
const nativeLocale = i18nextFormat(useDefault(useLoad(getNativeLocale), 'de-CH'));
const isTesting = useLoad(getTesting);
const isOnline = useSync(getOnline, subscribeOnline);
const isDevServers = useDefault(useLoad(getDevServers), false);
const isDevServers = useDevServers();
const [guideShown, setGuideShown] = useState(false);
const [guideExists, setGuideExists] = useState(false);
const [hideAmounts, setHideAmounts] = useState(false);
Expand Down
17 changes: 17 additions & 0 deletions frontends/web/src/hooks/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: Apache-2.0

import { getDevServers } from '@/api/environment';
import { useLoad } from './api';
import { useDefault } from './default';

export const useDevServers = () => {
const isDevServers = useDefault(
useLoad(
import.meta.env.PROD

@sutterseba sutterseba Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

? () => Promise.resolve(false)
: getDevServers
),
false
);
return isDevServers;
};
Loading