blob: 5b1bc8ccaa5c00b3344696ef564bbefbe16e5f20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import type { APIRoute } from "astro";
import { env } from "../../lib/environment.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" },
});
};
|