From 31c0aced4a6168438bbbb43178ee65920297802e Mon Sep 17 00:00:00 2001 From: mrkmntal Date: Fri, 17 Apr 2026 17:11:11 -0400 Subject: [PATCH] Update hazard list API to use relative URLS. (Much better for subdirectory hosting!) --- server/scripts/modules/hazard-list.mjs | 3 ++- server/scripts/modules/hazards.mjs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/scripts/modules/hazard-list.mjs b/server/scripts/modules/hazard-list.mjs index 87ec98f..c1a7b4c 100644 --- a/server/scripts/modules/hazard-list.mjs +++ b/server/scripts/modules/hazard-list.mjs @@ -2,6 +2,7 @@ import STATUS from './status.mjs'; import WeatherDisplay from './weatherdisplay.mjs'; import { registerDisplay } from './navigation.mjs'; +import { withBasePath } from './utils/base-path.mjs'; class HazardList extends WeatherDisplay { constructor(navId, elemId) { @@ -14,7 +15,7 @@ class HazardList extends WeatherDisplay { try { // Fetch hazard history from backend - const response = await fetch('/api/hazard-history'); + const response = await fetch(withBasePath('api/hazard-history')); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } diff --git a/server/scripts/modules/hazards.mjs b/server/scripts/modules/hazards.mjs index 3fb5a38..6d844be 100644 --- a/server/scripts/modules/hazards.mjs +++ b/server/scripts/modules/hazards.mjs @@ -8,6 +8,7 @@ import WeatherDisplay from './weatherdisplay.mjs'; import { registerDisplay } from './navigation.mjs'; import calculateScrollTiming from './utils/scroll-timing.mjs'; import { debugFlag } from './utils/debug.mjs'; +import { withBasePath } from './utils/base-path.mjs'; const hazardLevels = { Extreme: 10, @@ -289,7 +290,7 @@ class Hazards extends WeatherDisplay { })); // Send to backend - await fetch('/api/hazard-history', { + await fetch(withBasePath('api/hazard-history'), { method: 'POST', headers: { 'Content-Type': 'application/json',