diff --git a/.env.example b/.env.example index 656d727..90498e7 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,10 @@ # testnet | mainnet (default: testnet) STELLAR_NETWORK=testnet +# Frontend network — must match STELLAR_NETWORK; Vite requires the VITE_ prefix +# to expose env vars to the browser bundle at build time. +VITE_STELLAR_NETWORK=testnet + # Horizon REST API for the chosen network HORIZON_URL=https://horizon-testnet.stellar.org diff --git a/docker-compose.yml b/docker-compose.yml index 061aa00..6287ed7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,7 +40,10 @@ services: restart: unless-stopped frontend: - build: ./frontend + build: + context: ./frontend + args: + VITE_STELLAR_NETWORK: ${STELLAR_NETWORK:-testnet} # No ports exposed — nginx serves static assets from ./frontend/dist volume depends_on: backend: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index d9fef8e..f6fe884 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -7,6 +7,10 @@ RUN npm install COPY . . +# Accept network at build time so Vite bakes it into the static bundle +ARG VITE_STELLAR_NETWORK=testnet +ENV VITE_STELLAR_NETWORK=$VITE_STELLAR_NETWORK + RUN npm run build diff --git a/frontend/src/components/DemoBanner.jsx b/frontend/src/components/DemoBanner.jsx index 2d674a4..4025289 100644 --- a/frontend/src/components/DemoBanner.jsx +++ b/frontend/src/components/DemoBanner.jsx @@ -1,7 +1,25 @@ +import { isTestnet } from '../config/network'; + export default function DemoBanner() { + if (!isTestnet) return null; + return ( -
- ⚠️ PUBLIC DEMO ENVIRONMENT — Connected to Stellar Testnet. Records are simulated and database is wiped weekly. Do not enter real medical data. +
+ TESTNET ENVIRONMENT -- Connected to Stellar Testnet. Records are simulated and the database is wiped weekly. Do not enter real medical data.
); -} \ No newline at end of file +} diff --git a/frontend/src/components/NavBar.jsx b/frontend/src/components/NavBar.jsx index eb6035e..e7429e5 100644 --- a/frontend/src/components/NavBar.jsx +++ b/frontend/src/components/NavBar.jsx @@ -5,6 +5,7 @@ import Tooltip from './Tooltip'; import WalletConnectionProgress from './WalletConnectionProgress'; import { useAuth } from '../hooks/useFreighter'; import FeedbackButton from './FeedbackButton'; +import NetworkBadge from './NetworkBadge'; const NAV_LINKS = [ { to: '/', label: 'Home' }, @@ -194,7 +195,10 @@ export default function NavBar({ dark, onToggleDark }) { return (