From 2188ae19648a76c1894c78a7ef6ed043f3a7b5d6 Mon Sep 17 00:00:00 2001 From: "planetrenox@protonmail.com" Date: Tue, 20 Oct 2026 18:04:00 +0000 Subject: [PATCH] Feat: Send NTFY_TOKEN with alerts so the ntfy topic can be private Co-Authored-By: Claude Opus 5.5 --- README.md | 1 + functions/[[path]].js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9bd5805..c0ae1c9 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,7 @@ Create in your Cloudflare dashboard: | `SURREAL_USER` | SurrealDB username | Yes | | `SURREAL_PASS` | SurrealDB password | Yes | | `NTFY_URL` | ntfy.sh topic URL for alerts | Optional | +| `NTFY_TOKEN` | ntfy token that can write to the `NTFY_URL` topic, if the topic is protected | Optional | | `GOATCOUNTER_URL` | GoatCounter site URL for image hit analytics (e.g. `https://direct-img.goatcounter.com`) | Optional | | `GOATCOUNTER_TOKEN` | GoatCounter API token with "Record pageviews" permission | Optional | | `AURORA_API_KEY` | Key for the [AuroraIMG-6M API](https://github.com/direct-img/AuroraIMG-6M) (AI images, and the fallback for an `?i=` past a search's working images). Without it, `ai.` and those `?i=` serve `bad.webp` | Optional | diff --git a/functions/[[path]].js b/functions/[[path]].js index b4f93db..6073e8f 100644 --- a/functions/[[path]].js +++ b/functions/[[path]].js @@ -344,7 +344,7 @@ async function notify(env,{ title, message, tags, priority }) { if (!env.NTFY_URL) return; const endpoint = env.NTFY_URL.startsWith("http") ? env.NTFY_URL : `https://${env.NTFY_URL}`; try { - await fetch(endpoint, { method: "POST", body: message, headers: { "Title": title, "Tags": tags, "Priority": priority.toString() } }); + await fetch(endpoint, { method: "POST", body: message, headers: { "Title": title, "Tags": tags, "Priority": priority.toString(), ...(env.NTFY_TOKEN && { "Authorization": `Bearer ${env.NTFY_TOKEN}` }) } }); } catch {} }