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" }, }); };