Skip to content

Commit a9b01ec

Browse files
committed
Configure production environment variables and router basename
- Add configurable REACT_APP_BASENAME for flexible deployment paths - Update BrowserRouter to use environment variable for basename - Fix wallet auth to use config.walletBaseURL instead of hardcoded URLs - Remove .env.production from tracking and add .env.production.example - Reset .env.development to localhost URLs for development
1 parent 2372a67 commit a9b01ec

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ REACT_APP_BASE_URL=http://localhost:9002
22
REACT_APP_WALLET_BASE_URL=http://localhost:9003
33
REACT_APP_ASSETS_BUCKET=http://localhost
44
REACT_APP_DEMO_MODE=false
5+
REACT_APP_BASENAME=
56

67
# More info https://create-react-app.dev/docs/advanced-configuration
78
ESLINT_NO_DEV_ERRORS=true

.env.production

Lines changed: 0 additions & 8 deletions
This file was deleted.

.env.production.example

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Production Environment Configuration Example
2+
# Copy this file to .env.production and update with your actual values
3+
4+
# API Base URLs - Update these to your actual backend URLs
5+
REACT_APP_BASE_URL=https://your-domain.com/panel
6+
REACT_APP_WALLET_BASE_URL=https://your-domain.com/wallet
7+
8+
# Asset serving configuration
9+
REACT_APP_ASSETS_BUCKET=https://your-domain.com
10+
11+
# Demo mode (set to true for demo, false for production)
12+
REACT_APP_DEMO_MODE=false
13+
14+
# Router basename - where your React app will be served from
15+
# Use empty string for root path, or /admin, /dashboard, etc.
16+
REACT_APP_BASENAME=/front
17+
18+
# Public URL for static assets - should match REACT_APP_BASENAME
19+
PUBLIC_URL=/front
20+
21+
# More info https://create-react-app.dev/docs/advanced-configuration
22+
ESLINT_NO_DEV_ERRORS=true
23+
TSC_COMPILE_ON_ERROR=true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
.env.development.local
2323
.env.test.local
2424
.env.production.local
25+
.env.production
2526

2627
npm-debug.log*
2728
yarn-debug.log*

src/components/router/AppRouter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const LogoutFallback = withLoading(Logout);
143143

144144
export const AppRouter: React.FC = () => {
145145
return (
146-
<BrowserRouter>
146+
<BrowserRouter basename={process.env.REACT_APP_BASENAME || undefined}>
147147
<Routes>
148148
{/* Public routes */}
149149
<Route path="/auth" element={<AuthLayoutFallback>{/* children if any */}</AuthLayoutFallback>}>

src/hooks/useWalletAuth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const useWalletAuth = () => {
4343
const npub = await window.nostr.getPublicKey();
4444

4545
// Fetch the challenge from the server
46-
const challengeResponse = await fetch('http://localhost:9003/challenge', { method: 'GET' });
46+
const challengeResponse = await fetch(`${config.walletBaseURL}/challenge`, { method: 'GET' });
4747

4848
// Check if the response is valid JSON
4949
if (!challengeResponse.ok) {
@@ -64,7 +64,7 @@ const useWalletAuth = () => {
6464
});
6565

6666
// Send the signed challenge to the backend for verification
67-
const verifyResponse = await fetch('http://localhost:9003/verify', {
67+
const verifyResponse = await fetch(`${config.walletBaseURL}/verify`, {
6868
method: 'POST',
6969
headers: { 'Content-Type': 'application/json' },
7070
body: JSON.stringify({

0 commit comments

Comments
 (0)