[object Object]

← back to AbramsEgo

add creds-in-URL fetch guard to gated pages (TK-10984)

ab7216ade88c6e60c4a23ead78d0b205fb1ebe89 · 2026-08-30 22:58:27 -0700 · Steve Abrams

Files touched

Diff

commit ab7216ade88c6e60c4a23ead78d0b205fb1ebe89
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sun Aug 30 22:58:27 2026 -0700

    add creds-in-URL fetch guard to gated pages (TK-10984)
---
 public/dungeon.html | 24 ++++++++++++++++++++++++
 public/landing.html | 24 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/public/dungeon.html b/public/dungeon.html
index 3aa8a284..2dedc5ba 100644
--- a/public/dungeon.html
+++ b/public/dungeon.html
@@ -1,5 +1,29 @@
 <!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"><meta name="viewport" content="width=device-width,initial-scale=1">
 <title>AbramsEgo — The Dungeon</title>
 <style>
diff --git a/public/landing.html b/public/landing.html
index 1043d56a..43ab88fc 100644
--- a/public/landing.html
+++ b/public/landing.html
@@ -1,6 +1,30 @@
 <!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" />
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <title>AbramsEgo · the dashboard that pays for itself</title>

← fb739bb6 auto-data-snapshot: 2026-08-30T22:46:38 (1 data files) — dat  ·  back to AbramsEgo  ·  auto-data-snapshot: 2026-08-30T23:23:51 (1 data files) — dat 659c550c →