diff --git a/apps/react-wallet/vite.config.ts b/apps/react-wallet/vite.config.ts index 5056dd56..5d24122c 100644 --- a/apps/react-wallet/vite.config.ts +++ b/apps/react-wallet/vite.config.ts @@ -10,6 +10,12 @@ export default defineConfig({ server: { host: true, port, + allowedHosts: ['wallet.archon.technology', 'localhost'], + }, + preview: { + host: true, + port, + allowedHosts: ['wallet.archon.technology', 'localhost'], }, resolve: { alias: { diff --git a/services/explorer/sample.env b/services/explorer/sample.env index cce0d291..ff8c83dd 100644 --- a/services/explorer/sample.env +++ b/services/explorer/sample.env @@ -2,3 +2,4 @@ VITE_EXPLORER_PORT=4000 VITE_GATEKEEPER_URL=http://localhost:4224 VITE_SEARCH_SERVER=http://localhost:4224 VITE_OPERATION_NETWORKS=hyperswarm,BTC:signet,BTC:testnet4 +ARCHON_ADMIN_API_KEY= diff --git a/services/explorer/server.js b/services/explorer/server.js index a02ddfda..67a33421 100644 --- a/services/explorer/server.js +++ b/services/explorer/server.js @@ -1,5 +1,6 @@ import express from 'express'; import path from 'path'; +import fs from 'fs'; import { fileURLToPath } from 'url'; import dotenv from 'dotenv'; @@ -10,11 +11,25 @@ const __dirname = path.dirname(__filename); const app = express(); const port = process.env.VITE_EXPLORER_PORT || 4000; +const adminApiKey = process.env.ARCHON_ADMIN_API_KEY || ''; -app.use(express.static(path.join(__dirname, 'dist'))); +// Cache the modified index.html +let indexHtml = null; +function getIndexHtml() { + if (!indexHtml) { + const rawHtml = fs.readFileSync(path.join(__dirname, 'dist', 'index.html'), 'utf-8'); + const configScript = ``; + indexHtml = rawHtml.replace('
', `\n ${configScript}`); + } + return indexHtml; +} + +app.use(express.static(path.join(__dirname, 'dist'), { + index: false // Don't serve index.html automatically +})); app.get('{*path}', (req, res) => { - res.sendFile(path.join(__dirname, 'dist', 'index.html')); + res.type('html').send(getIndexHtml()); }); app.listen(port, () => { diff --git a/services/explorer/src/App.tsx b/services/explorer/src/App.tsx index 51576440..fc287390 100644 --- a/services/explorer/src/App.tsx +++ b/services/explorer/src/App.tsx @@ -23,7 +23,18 @@ interface SnackbarState { severity: AlertColor; } +interface ArchonConfig { + apiKey?: string; +} + +declare global { + interface Window { + __ARCHON_CONFIG__?: ArchonConfig; + } +} + const gatekeeperUrl = import.meta.env.VITE_GATEKEEPER_URL || 'http://localhost:4224'; +const apiKey = window.__ARCHON_CONFIG__?.apiKey || ''; function App() { const [isReady, setIsReady] = useState