This commit is contained in:
pradeepkumar
2026-01-24 23:10:02 +05:30
parent b940e77a67
commit 39af9bc59d
8 changed files with 496 additions and 103 deletions

22
src/lib/imageProxy.ts Normal file
View File

@@ -0,0 +1,22 @@
/**
* Convert S3 URL to proxy URL through backend API
* This is needed because S3 bucket might not have public read access
*/
export function getProxyImageUrl(url: string | null | undefined): string {
if (!url) {
return '/assets/demo_images/8f017153a7b4a239a4f0691234ef97dd55092282.jpg';
}
// If it's already a local URL or data URL, return as-is
if (url.startsWith('/') || url.startsWith('data:')) {
return url;
}
// If it's an S3/external URL, proxy through backend
if (url.startsWith('http')) {
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001/api/v1';
return `${apiUrl}/upload/image?url=${encodeURIComponent(url)}`;
}
return url;
}