服务器代理豆瓣反防盗链
This commit is contained in:
@@ -17,6 +17,7 @@ export async function GET(request: Request) {
|
|||||||
'User-Agent':
|
'User-Agent':
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
|
||||||
Accept: 'image/jpeg,image/png,image/gif,*/*;q=0.8',
|
Accept: 'image/jpeg,image/png,image/gif,*/*;q=0.8',
|
||||||
|
Referer: 'https://movie.douban.com/',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useEffect, useState, useCallback, useRef } from 'react';
|
|||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { getTMDBImageUrl, getGenreNames, type TMDBItem } from '@/lib/tmdb.client';
|
import { getTMDBImageUrl, getGenreNames, type TMDBItem } from '@/lib/tmdb.client';
|
||||||
|
import { processImageUrl } from '@/lib/utils';
|
||||||
import { ChevronLeft, ChevronRight, Play } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, Play } from 'lucide-react';
|
||||||
|
|
||||||
interface BannerCarouselProps {
|
interface BannerCarouselProps {
|
||||||
@@ -48,14 +49,9 @@ export default function BannerCarousel({ autoPlayInterval = 5000 }: BannerCarous
|
|||||||
// 获取图片URL(处理TX完整URL和TMDB路径)
|
// 获取图片URL(处理TX完整URL和TMDB路径)
|
||||||
const getImageUrl = (path: string | null) => {
|
const getImageUrl = (path: string | null) => {
|
||||||
if (!path) return '';
|
if (!path) return '';
|
||||||
// 如果是完整URL(TX数据源或豆瓣),需要判断是否需要代理
|
// 如果是完整URL(TX数据源或豆瓣),使用processImageUrl统一处理
|
||||||
if (path.startsWith('http://') || path.startsWith('https://')) {
|
if (path.startsWith('http://') || path.startsWith('https://')) {
|
||||||
// 豆瓣图片直接使用服务器代理
|
return processImageUrl(path);
|
||||||
if (path.includes('doubanio.com')) {
|
|
||||||
return `/api/image-proxy?url=${encodeURIComponent(path)}`;
|
|
||||||
}
|
|
||||||
// TX等其他完整URL直接返回
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
// 否则使用TMDB的URL拼接
|
// 否则使用TMDB的URL拼接
|
||||||
return getTMDBImageUrl(path, 'original');
|
return getTMDBImageUrl(path, 'original');
|
||||||
|
|||||||
Reference in New Issue
Block a user