Files
node-explorer/vite.config.ts
Kevin CodexandClaude Fable 5 a23f2249a8 Add node home, peers, events, tasks, and network sections (#8)
Expands the explorer from repos+agents into a full replacement for
gitlawb.com/node, with URL paths matching the old site 1:1 (minus the
/node prefix) so a single redirect covers the migration:

- / — node overview dashboard: identity, stat tiles, live activity
  feed, agent-task summary, p2p status, quick clone
- /peers — searchable peer directory with live per-peer ping checks
- /events — node-level ref-update feed with local/gossip filter and
  visibility-aware 30s auto-refresh
- /tasks + /tasks/:id — agent task queue with server-side status
  filter, payload-derived titles, and pretty-printed payload/result
- /network — fan-out to the 4 federation nodes with per-node cards
  and a replication-coverage table over their event feeds

Peer nodes serve no CORS headers, so node2/node3/manila get proxy
prefixes in vercel.json and the vite dev proxy. Section nav moves
from per-page tabs into the global layout.

Co-authored-by: Claude Fable 5 <[email protected]>
2026-07-05 22:32:29 +08:00

56 lines
1.6 KiB
TypeScript

/// <reference types="vitest/config" />
import path from 'path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
test: {
environment: 'node',
include: ['src/**/*.test.{ts,tsx}'],
},
server: {
proxy: {
'/api': {
target: 'https://node.gitlawb.com',
changeOrigin: true,
secure: true,
},
// Node identity lives at the node's root path, which the SPA occupies locally.
'/node-info': {
target: 'https://node.gitlawb.com',
changeOrigin: true,
secure: true,
rewrite: () => '/',
},
// Peer nodes for the network page (no CORS on nodes — same list as
// vercel.json and src/lib/nodes.ts). `/nodes/<id>/node-info` maps to the
// peer's root; everything else keeps its path with the prefix stripped.
...Object.fromEntries(
[
['node2', 'https://node2.gitlawb.com'],
['node3', 'https://node3.gitlawb.com'],
['manila', 'https://manila.gitlawb.com'],
].map(([id, target]) => [
`/nodes/${id}`,
{
target,
changeOrigin: true,
secure: true,
rewrite: (path: string) => {
const rest = path.slice(`/nodes/${id}`.length)
return rest === '/node-info' ? '/' : rest
},
},
]),
),
},
},
})