← back to Re Flyer Aggregator
flyers: restore load-failure .catch() in build template + rebuild
83517a70bd1bc481d3ab67be1fa18fcb84c9a2a7 · 2026-09-18 13:14:38 -0700 · Steve
Generated flyers page swallowed fetch('flyers.json') failures silently
(unhandled rejection -> blank grid) after a rebuild wiped a hand-patch.
Fix belongs in scripts/build-flyers-site.mjs so every rebuild emits a
visible 'Could not load flyers' error state. Public page, so the
credential-safe fetch guard is intentionally not re-added.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GApjY8mnjD5aYcopgpnS8y
Files touched
M public/flyers/index.htmlM scripts/build-flyers-site.mjs
Diff
commit 83517a70bd1bc481d3ab67be1fa18fcb84c9a2a7
Author: Steve <steve@designerwallcoverings.com>
Date: Fri Sep 18 13:14:38 2026 -0700
flyers: restore load-failure .catch() in build template + rebuild
Generated flyers page swallowed fetch('flyers.json') failures silently
(unhandled rejection -> blank grid) after a rebuild wiped a hand-patch.
Fix belongs in scripts/build-flyers-site.mjs so every rebuild emits a
visible 'Could not load flyers' error state. Public page, so the
credential-safe fetch guard is intentionally not re-added.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GApjY8mnjD5aYcopgpnS8y
---
public/flyers/index.html | 30 +++---------------------------
scripts/build-flyers-site.mjs | 4 +++-
2 files changed, 6 insertions(+), 28 deletions(-)
diff --git a/public/flyers/index.html b/public/flyers/index.html
index fc1035b..73ac0ec 100644
--- a/public/flyers/index.html
+++ b/public/flyers/index.html
@@ -1,28 +1,4 @@
-<!doctype html><html lang="en"><head>
-<script>
-// Credential-safe fetch guard (fleet drop-in) — if this page is opened with
-// credentials in the URL (a saved bookmark / Chrome-remembered basic-auth:
-// https://user:pass@host/…), the browser poisons document.baseURI, so any
-// relative or root-relative fetch('/api/…') throws "Request cannot be constructed
-// from a URL that includes credentials" and callers silently fall to an empty
-// state. Resolve every non-absolute request URL against the credential-free
-// location instead of baseURI. Placed first so it wraps window.fetch before any
-// app script runs. Ref: creds-in-url-fetch-guard-fleet-pattern.
-(function () {
- var _fetch = window.fetch.bind(window);
- var cleanBase = function () { return location.origin + location.pathname; };
- window.fetch = function (input, init) {
- try {
- if (typeof input === 'string' && !/^[a-z]+:\/\//i.test(input) && input.indexOf('//') !== 0) {
- input = new URL(input, cleanBase()).href;
- } else if (input instanceof Request && !/^[a-z]+:\/\//i.test(input.url)) {
- input = new Request(new URL(input.url, cleanBase()).href, input);
- }
- } catch (_) { /* fall through to native */ }
- return _fetch(input, init);
- };
-})();
-</script><meta charset="utf-8">
+<!doctype html><html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Flyers — Abrams | CRE deal flyers</title>
<style>
@@ -93,6 +69,6 @@ fetch('flyers.json').then(r=>r.json()).then(j=>{DEALS=j;
recency.value=localStorage.flyRecency||'0'; // default: All time (so full inventory shows, not just the ~47 fresh)
if(localStorage.flyDens)document.getElementById('dens').value=localStorage.flyDens;
dens();render();}).catch(e=>{
- document.getElementById('grid').innerHTML='<div style="grid-column:1/-1;padding:40px;text-align:center;color:#b91c1c;font-size:14px">Could not load flyers ('+(e&&e.message||e)+'). Try reloading without credentials in the URL.</div>';
- document.getElementById('stat').textContent='load failed';});
+ grid.innerHTML='<div style="grid-column:1/-1;padding:40px;text-align:center;color:#b91c1c;font-size:14px">Could not load flyers ('+(e&&e.message||e)+'). Please reload.</div>';
+ stat.textContent='load failed';});
</script></body></html>
\ No newline at end of file
diff --git a/scripts/build-flyers-site.mjs b/scripts/build-flyers-site.mjs
index 214bfe5..c521c7e 100644
--- a/scripts/build-flyers-site.mjs
+++ b/scripts/build-flyers-site.mjs
@@ -119,7 +119,9 @@ fetch('flyers.json').then(r=>r.json()).then(j=>{DEALS=j;
sort.value=localStorage.flySort||'date'; // default: Newest first (freshest deals on top)
recency.value=localStorage.flyRecency||'0'; // default: All time (so full inventory shows, not just the ~47 fresh)
if(localStorage.flyDens)document.getElementById('dens').value=localStorage.flyDens;
- dens();render();});
+ dens();render();}).catch(e=>{
+ grid.innerHTML='<div style="grid-column:1/-1;padding:40px;text-align:center;color:#b91c1c;font-size:14px">Could not load flyers ('+(e&&e.message||e)+'). Please reload.</div>';
+ stat.textContent='load failed';});
</script></body></html>`;
writeFileSync(join(SITE, 'index.html'), html);
console.log(`Wrote public/flyers/index.html + flyers.json — ${deals.length} flyers (${new Set(deals.map(d=>d.market)).size} markets, types: ${[...new Set(deals.map(d=>d.type))].join('/')})`);
← 6933ee2 auto-data-snapshot: 2026-09-18T13:12:29 (6 data files) — dat
·
back to Re Flyer Aggregator
·
auto-data-snapshot: 2026-09-18T16:30:11 (6 data files) — dat b6f512d →