mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-08 07:28:37 +08:00
fix: proxy B站图片 CDN 解决 web 端防盗链图片不显示问题
- dev-proxy.js 新增 /bilibili-img 路由,代理 *.hdslb.com 并注入正确 Referer - utils/imageUrl.ts 新增 proxyImageUrl(),web 端将图片 URL 转为本地代理地址 - VideoCard / CommentItem / MiniPlayer / [bvid] 对所有 B站图片应用 proxyImageUrl
This commit is contained in:
13
utils/imageUrl.ts
Normal file
13
utils/imageUrl.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
/**
|
||||
* Web 端将 B站图片 CDN URL 转为本地代理地址,注入正确 Referer 绕过防盗链。
|
||||
* Native 端直接返回原 URL(App 请求头由 axios 拦截器统一设置)。
|
||||
*/
|
||||
export function proxyImageUrl(url: string): string {
|
||||
if (Platform.OS !== 'web' || !url) return url;
|
||||
return url.replace(
|
||||
/^https?:\/\/([a-z0-9]+\.hdslb\.com)/,
|
||||
'http://localhost:3001/bilibili-img/$1',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user