mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-07 23:18:38 +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:
@@ -56,5 +56,14 @@ function makeProxy(targetHost) {
|
||||
app.use('/bilibili-api', makeProxy('api.bilibili.com'));
|
||||
app.use('/bilibili-passport', makeProxy('passport.bilibili.com'));
|
||||
|
||||
// Image CDN proxy — strips the host segment and forwards to the real CDN with Referer
|
||||
app.use('/bilibili-img', (req, res) => {
|
||||
const parts = req.url.split('/').filter(Boolean);
|
||||
const host = parts[0];
|
||||
if (!host || !host.endsWith('.hdslb.com')) return res.status(403).end();
|
||||
req.url = '/' + parts.slice(1).join('/');
|
||||
makeProxy(host)(req, res);
|
||||
});
|
||||
|
||||
const PORT = process.env.PROXY_PORT || 3001;
|
||||
app.listen(PORT, () => console.log(`[Proxy] http://localhost:${PORT}`));
|
||||
|
||||
Reference in New Issue
Block a user