From 6793e22fb093310e56d653d9f71ecf4696b802c8 Mon Sep 17 00:00:00 2001 From: flaxscrip Date: Fri, 27 Feb 2026 16:54:15 -0500 Subject: [PATCH 1/3] feat(explorer): Add ARCHON_ADMIN_API_KEY support - server.js: Inject window.__ARCHON_CONFIG__ with apiKey into index.html - App.tsx: Read apiKey from config and pass to gatekeeper.connect() - sample.env: Add ARCHON_ADMIN_API_KEY placeholder Fixes 401 on /api/v1/dids/export when admin key protection is enabled. --- services/explorer/sample.env | 1 + services/explorer/server.js | 21 ++++++++++++++++++--- services/explorer/src/App.tsx | 12 ++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) 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..ad77d051 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.get('{*path}', (req, res) => { - res.sendFile(path.join(__dirname, 'dist', 'index.html')); +app.use(express.static(path.join(__dirname, 'dist'), { + index: false // Don't serve index.html automatically +})); + +app.get('*', (req, res) => { + 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(false); @@ -96,6 +107,7 @@ function App() { waitUntilReady: true, intervalSeconds: 5, chatty: true, + apiKey: apiKey || undefined, }); interval = setInterval(async () => { From f062402edf9a28a374083f2305c8dcaccb3abdb8 Mon Sep 17 00:00:00 2001 From: flaxscrip Date: Fri, 27 Feb 2026 17:02:33 -0500 Subject: [PATCH 2/3] fix(explorer): Use correct wildcard route syntax for path-to-regexp --- services/explorer/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/explorer/server.js b/services/explorer/server.js index ad77d051..67a33421 100644 --- a/services/explorer/server.js +++ b/services/explorer/server.js @@ -28,7 +28,7 @@ app.use(express.static(path.join(__dirname, 'dist'), { index: false // Don't serve index.html automatically })); -app.get('*', (req, res) => { +app.get('{*path}', (req, res) => { res.type('html').send(getIndexHtml()); }); From a337f46e019dd9987854c9011ecc92d8fb48dd3d Mon Sep 17 00:00:00 2001 From: flaxscrip Date: Fri, 27 Feb 2026 18:29:57 -0500 Subject: [PATCH 3/3] fix(wallet): Add wallet.archon.technology to allowedHosts Add allowedHosts to both server and preview configs to allow wallet.archon.technology domain. --- apps/react-wallet/vite.config.ts | 6 ++++++ 1 file changed, 6 insertions(+) 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: {