fix: use upstream hostname
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Kieran 2024-03-17 19:35:35 +00:00
parent e6943e6747
commit 8dd74affa7

View File

@ -6,13 +6,15 @@ interface NostrJson {
nip46?: Record<string, Array<string>>; nip46?: Record<string, Array<string>>;
} }
async function fetchNip05Pubkey(name: string, domain: string, timeout = 2_000): Promise<string | undefined> { async function fetchNip05Pubkey(name: string, timeout = 2_000): Promise<string | undefined> {
if (!name || !domain) { if (!name) {
return undefined; return undefined;
} }
try { try {
const res = await fetch(`https://${domain}/.well-known/nostr.json?name=${encodeURIComponent(name)}`, { const res = await fetch(`https://api.snort.social/.well-known/nostr.json?name=${encodeURIComponent(name)}`, {
signal: AbortSignal.timeout(timeout), headers: {
"X-Proxy-Host": "zap.stream",
},
}); });
const data: NostrJson = await res.json(); const data: NostrJson = await res.json();
const match = Object.keys(data.names).find(n => { const match = Object.keys(data.names).find(n => {
@ -29,7 +31,7 @@ export const onRequest: PagesFunction<Env> = async context => {
const handle = context.params.handle as string | undefined; const handle = context.params.handle as string | undefined;
let pubkey = handle; let pubkey = handle;
if (handle && handle.length !== 64) { if (handle && handle.length !== 64) {
const nip5 = await fetchNip05Pubkey(handle, "zap.stream"); const nip5 = await fetchNip05Pubkey(handle);
if (nip5) { if (nip5) {
pubkey = nip5; pubkey = nip5;
} }