feat: thêm cái proxy hình ảnh dùng webp

This commit is contained in:
ngthanhvu
2026-07-30 22:32:44 -04:00
parent 2ab5766e02
commit 63ef322ccf
9 changed files with 727 additions and 22 deletions
+20
View File
@@ -0,0 +1,20 @@
/**
* Transform image URLs to use the internal image proxy.
* This converts remote images to WebP format for faster loading.
*/
export function proxyImageUrl(url: string): string {
if (!url) return ''
if (url.startsWith('/api/image-proxy')) return url
// Nếu đã có sẵn query params
const separator = url.includes('?') ? '&' : '?'
return `/api/image-proxy?url=${encodeURIComponent(url)}`
}
export function proxyThumbUrl(url: string): string {
return proxyImageUrl(url)
}
export function proxyPosterUrl(url: string): string {
return proxyImageUrl(url)
}