Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review: delegate access-URL banner to a shared node script
[._.]/ Adam Eivyc96b45714d40
diff --git a/scripts/print-access-url.js b/scripts/print-access-url.jsnew file mode 100644index 0000000000..ad5ee754d3--- /dev/null+++ b/scripts/print-access-url.js@@ -0,0 +1,39 @@+#!/usr/bin/env node+/**+ * Print the URL(s) the user should open to reach PortOS, gated on the same+ * cert detection the server uses (`hasTailscaleCert` from+ * lib/tailscale-https.js — checks file presence AND PEM parseability).+ * Called from setup.sh's final banner so we never advertise an HTTPS URL the+ * server isn't actually serving (e.g. corrupt cert files would let the server+ * boot HTTP-only while setup.sh's file-presence check still claimed HTTPS).+ */+import { hasTailscaleCert } from '../lib/tailscale-https.js';+import { readFileSync } from 'fs';+import { join, dirname } from 'path';+import { fileURLToPath } from 'url';++const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');+const CERT_DIR = join(ROOT, 'data', 'certs');+const META_PATH = join(CERT_DIR, 'meta.json');+const API_PORT = Number(process.env.PORT) || 5555;+const MIRROR_PORT = Number(process.env.PORTOS_HTTP_PORT) || 5553;++if (!hasTailscaleCert(CERT_DIR)) {+ console.log(`Access at: http://localhost:${API_PORT}`);+ process.exit(0);+}++let mode = '';+try {+ mode = JSON.parse(readFileSync(META_PATH, 'utf-8')).mode || '';+} catch { /* meta unreadable — fall through to generic warning */ }++console.log(`Access at: http://localhost:${MIRROR_PORT} (loopback HTTP mirror — no cert warning)`);+if (mode === 'tailscale') {+ console.log(` or: https://<machine>.<tailnet>.ts.net:${API_PORT} (trusted via Tailscale)`);+ console.log(` or: https://localhost:${API_PORT} (browser warns — cert is for the Tailscale hostname)`);+} else if (mode === 'self-signed') {+ console.log(` or: https://localhost:${API_PORT} (browser warns on first visit — self-signed cert)`);+} else {+ console.log(` or: https://localhost:${API_PORT} (browser may warn on cert)`);+}diff --git a/setup.sh b/setup.shindex 5e8931a82b..5933150c0a 100755--- a/setup.sh+++ b/setup.sh@@ -93,34 +93,11 @@ if [ -t 0 ]; thendonefi-# Print the URL the user should open. The server flips between HTTP and HTTPS-# on :5555 based on whether data/certs/{cert,key}.pem exist (see-# lib/tailscale-https.js). When HTTPS is active, :5555 speaks TLS only — plain-# http://localhost:5555 hits a TLS mismatch — and a loopback HTTP mirror spawns-# on :5553 (or $PORTOS_HTTP_PORT) for cert-free local access.+# Print the URL the user should open. Delegates to scripts/print-access-url.js+# so we share the same cert detection (file presence AND PEM parseability) the+# server uses — otherwise we'd advertise HTTPS URLs the server isn't serving.print_access_url() {- if [ ! -f data/certs/cert.pem ] || [ ! -f data/certs/key.pem ]; then- echo "Access at: http://localhost:5555"- return- fi- local mirror_port="${PORTOS_HTTP_PORT:-5553}"- # Read cert mode from meta.json — self-signed certs cover localhost + local- # IPv4s but not the Tailscale hostname; Tailscale LE certs cover the- # tailnet hostname but not localhost. The advertised URLs must match the- # cert's SAN coverage or we'll send users to a URL their browser rejects.- local cert_mode=""- if [ -f data/certs/meta.json ]; then- cert_mode=$(node -e "try{process.stdout.write(JSON.parse(require('fs').readFileSync('data/certs/meta.json','utf8')).mode||'')}catch{}" 2>/dev/null)- fi- echo "Access at: http://localhost:${mirror_port} (loopback HTTP mirror — no cert warning)"- if [ "$cert_mode" = "tailscale" ]; then- echo " or: https://<machine>.<tailnet>.ts.net:5555 (trusted via Tailscale)"- echo " or: https://localhost:5555 (browser warns — cert is for the Tailscale hostname)"- elif [ "$cert_mode" = "self-signed" ]; then- echo " or: https://localhost:5555 (browser warns on first visit — self-signed cert)"- else- echo " or: https://localhost:5555 (browser may warn on cert)"- fi+ node scripts/print-access-url.js}if [ "$start_now" = "1" ]; then