Files
Shadowbroker/frontend
C3B2W23andClaude Fable 5.1 667f51cb7a fix(basemap): serve CARTO key from backend, bound the map gate, add source attribution
Review follow-up:

- Drop the Next.js route. CARTO_API_KEY is now a regular backend registry
  key (env, .env, or the API Keys panel) served by public
  GET /api/basemap-config. Every frontend mode already proxies /api/* to
  the backend (Next.js proxy in web mode, companion server in packaged
  desktop), so this covers web and desktop with one mechanism and leaves
  the static export untouched. Also removes the invalid non-handler
  export from the route module by removing the module.
- useBasemapConfig: fail open to the unkeyed style after 3 s, abort the
  request at 15 s, apply a late key when it arrives, cache successes per
  page and retry failures on the next mount.
- Declare OSM/CARTO attribution on the raster source (same markup as the
  viewer's existing AttributionControl so MapLibre de-duplicates it).
- Tests: backend endpoint (unset / set+trimmed / persisted operator key /
  registry), hook behaviour (success, non-OK, network error, soft timeout
  then late key, hard abort, shared request and retry), attribution and
  gating source checks.
- CARTO_API_KEY moves to the backend service in docker-compose.yml; docs
  updated accordingly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 15:16:47 -07:00
..
2026-05-01 22:56:50 -06:00
2026-03-04 22:44:08 -07:00
2026-05-01 22:56:50 -06:00

ShadowBroker Frontend

Next.js 16 dashboard with MapLibre GL and Framer Motion.

Development

npm install
npm run dev        # http://localhost:3000

API URL Configuration

The browser calls relative /api/* paths. The catch-all route handler at src/app/api/[...path]/route.ts proxies those requests to the backend using the server-side BACKEND_URL environment variable at request time.

This keeps the backend URL out of the client bundle and lets Docker or other deployments change the backend target without rebuilding the frontend.

Common Scenarios

Scenario Action needed
Local dev (localhost:3000 + backend on 127.0.0.1:8000) None. The proxy defaults to http://127.0.0.1:8000.
Docker Compose None. docker-compose.yml sets BACKEND_URL=http://backend:8000.
Backend on a different host or port Set BACKEND_URL before starting the Next.js server/container.
Reverse proxy in front of the frontend Point external clients at the frontend; keep BACKEND_URL set to the backend address reachable from the Next.js server.

Setting BACKEND_URL

# Shell (Linux/macOS)
BACKEND_URL=http://myserver:8000 npm run dev

# PowerShell (Windows)
$env:BACKEND_URL="http://myserver:8000"; npm run dev

# Docker Compose
# Edit the frontend service environment or add a compose override:
# BACKEND_URL=http://myserver:8000

Theming

Dark mode is the default. A light/dark toggle is available in the left panel toolbar. Theme preference is persisted in localStorage as sb-theme and applied via the data-theme attribute on <html>. CSS variables in globals.css define all structural colors for both themes.