Feature: Image Proxy (#122)

* feat: Implement image proxying functionality in KIND20Card and QuickViewKind20NoteCard components

* fix: Enhance image error handling in KIND20Card and QuickViewKind20NoteCard components

* feat: Add imgproxy configuration instructions to README for image proxying support

---------

Co-authored-by: highperfocused <highperfocused@pm.me>
This commit is contained in:
mroxso
2025-05-25 22:28:01 +02:00
committed by GitHub
parent 8b53f5da79
commit 8d7d028b88
5 changed files with 94 additions and 27 deletions

View File

@@ -54,4 +54,19 @@ export async function signEvent(loginType: string | null, event: NostrEvent): Pr
}
console.log(eventSigned);
return eventSigned;
}
// Create proxied image URL
export const getProxiedImageUrl = (url: string, width: number, height: number) => {
if (!url.startsWith("http")) return url;
try {
// Encode the URL to be used in the proxy
const encodedUrl = encodeURIComponent(url);
const imgproxyEnv = process.env.NEXT_PUBLIC_IMGPROXY_URL;
const imgproxyUrl = new URL(imgproxyEnv || "https://imgproxy.example.com");
return `${imgproxyUrl}_/resize:fit:${width}:${height}/plain/${encodedUrl}`;
} catch (error) {
console.error("Error creating proxied image URL:", error);
return url;
}
}