From 04bcfc551e3f446d26358971115ac27e34f03e44 Mon Sep 17 00:00:00 2001 From: João Augusto Costa Branco Marado Torres Date: Sun, 6 Jul 2025 13:05:13 -0300 Subject: feat: well known onion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Augusto Costa Branco Marado Torres --- src/pages/.well-known/onion.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/pages/.well-known/onion.ts (limited to 'src') diff --git a/src/pages/.well-known/onion.ts b/src/pages/.well-known/onion.ts new file mode 100644 index 0000000..552b5eb --- /dev/null +++ b/src/pages/.well-known/onion.ts @@ -0,0 +1,20 @@ +import type { APIRoute } from "astro"; +import { env } from "../../lib/env.ts"; + +const { PUBLIC_TOR_URL } = env; +export const GET: APIRoute = (): Response => { + if (PUBLIC_TOR_URL === undefined) { + return new Response(null, { status: 404 }); + } + + let url: URL; + try { + url = new URL(PUBLIC_TOR_URL); + } catch { + return new Response("Invalid Tor URL", { status: 400 }); + } + + return new Response(url.host, { + headers: { "Onion-Location": url.href, "Content-Type": "text/plain" }, + }); +}; -- cgit v1.2.3