diff options
author | João Augusto Costa Branco Marado Torres <torres.dev@disroot.org> | 2025-07-06 13:05:13 -0300 |
---|---|---|
committer | João Augusto Costa Branco Marado Torres <torres.dev@disroot.org> | 2025-07-06 13:05:13 -0300 |
commit | 04bcfc551e3f446d26358971115ac27e34f03e44 (patch) | |
tree | 49beab8a529259b1fc2bf55510cc8ec458039dee /src/pages | |
parent | a27e3dd7e9a01ea9ca472229bf8592b9b3fc8c84 (diff) |
feat: well known onion
Signed-off-by: João Augusto Costa Branco Marado Torres <torres.dev@disroot.org>
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/.well-known/onion.ts | 20 |
1 files changed, 20 insertions, 0 deletions
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" }, + }); +}; |