Skip to content
Closed
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
6 changes: 6 additions & 0 deletions apps/react-wallet/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions services/explorer/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -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=
19 changes: 17 additions & 2 deletions services/explorer/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import express from 'express';
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
import dotenv from 'dotenv';

Expand All @@ -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 = `<script>window.__ARCHON_CONFIG__ = { apiKey: "${adminApiKey}" };</script>`;
indexHtml = rawHtml.replace('<head>', `<head>\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, () => {
Expand Down
12 changes: 12 additions & 0 deletions services/explorer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(false);
Expand Down Expand Up @@ -96,6 +107,7 @@ function App() {
waitUntilReady: true,
intervalSeconds: 5,
chatty: true,
apiKey: apiKey || undefined,
});

interval = setInterval(async () => {
Expand Down
Loading