Spaces:
Sleeping
Sleeping
Download src/lib/image.js from TXAVLOG/dptxa-proxy: direct link, hf CLI and curl.
- Browser
- Download file 777 Bytes
-
https://huggingface.co/spaces/TXAVLOG/dptxa-proxy/resolve/main/src/lib/image.js
- Command line
-
hf download hf://spaces/TXAVLOG/dptxa-proxy/src/lib/image.js
-
curl -L -o image.js https://huggingface.co/spaces/TXAVLOG/dptxa-proxy/resolve/main/src/lib/image.js
777 Bytes
| const IMAGE_BASE_URL = 'https://phimimg.com'; | |
| /** | |
| * Hàm định dạng URL ảnh thành URL tuyệt đối (chạy được trên cả Client và Server) | |
| */ | |
| export const formatImageUrl = (url) => { | |
| if (!url) return ''; | |
| let finalUrl = url; | |
| if (!url.startsWith('http')) { | |
| const cleanUrl = url.startsWith('/') ? url : `/${url}`; | |
| finalUrl = `${IMAGE_BASE_URL}${cleanUrl}`; | |
| } | |
| if (finalUrl.includes('phim1280') || finalUrl.includes('s2.phim1280.tv') || finalUrl.includes('img.ophim.tv')) { | |
| const cloudflareProxy = import.meta.env.PUBLIC_CLOUDFLARE_PROXY_URL; | |
| if (cloudflareProxy) { | |
| return `${cloudflareProxy}/?url=${encodeURIComponent(finalUrl)}`; | |
| } | |
| return `/api/proxy-media?url=${encodeURIComponent(finalUrl)}`; | |
| } | |
| return finalUrl; | |
| }; | |