Add settings page for managing forecasting API key and URL via UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 14:37:36 +00:00
parent cae411eae7
commit 1c411e402e
19809 changed files with 1962608 additions and 97 deletions

View file

@ -1,12 +1,11 @@
import { requireAuth, hasCap } from '../auth.js'
import { pool } from '../db.js'
const FORECASTING_URL = process.env.FORECASTING_URL || 'http://10.10.10.113:3080'
import { pool, getSetting } from '../db.js'
async function fcFetch(path) {
const apiKey = process.env.FORECASTING_API_KEY
const apiKey = await getSetting('forecasting_api_key') || process.env.FORECASTING_API_KEY
const baseUrl = await getSetting('forecasting_url') || process.env.FORECASTING_URL || 'http://10.10.10.113:3080'
if (!apiKey) throw new Error('FORECASTING_API_KEY not configured')
const res = await fetch(`${FORECASTING_URL}/forecasting/api/public${path}`, {
const res = await fetch(`${baseUrl}/forecasting/api/public${path}`, {
headers: { 'X-API-Key': apiKey },
})
if (!res.ok) throw new Error(`Forecasting API ${res.status}${path}`)