feat(media): implement nextjs media proxy API routes (/api/uploads & /api/media) with server-side caching and streaming
This commit is contained in:
1 parent
d9c693c41b
commit
fa1a35c835
19 files changed
+13806
-13030
No files matched your search
@@ -17,6 +17,7 @@ import {
|
||||
ChevronUp
|
||||
} from "lucide-react";
|
||||
import SafeImage from "./SafeImage";
|
||||
import { getMediaUrl } from "../lib/media";
|
||||
|
||||
interface PodcastInlinePlayerProps {
|
||||
podcast: {
|
||||
@@ -177,7 +178,7 @@ export default function PodcastInlinePlayer({ podcast }: PodcastInlinePlayerProp
|
||||
return `${mins.toString().padStart(2, "0")}:${remainingSecs.toString().padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
const displayCover = podcast.cover || podcast.fallbackCover || '/images/default-podcast.png';
|
||||
const displayCover = getMediaUrl(podcast.cover || podcast.fallbackCover || '/images/default-podcast.png');
|
||||
const progressPercent = duration > 0 ? (currentTime / duration) * 100 : 0;
|
||||
const volumePercent = isMuted ? 0 : volume * 100;
|
||||
|
||||
@@ -186,7 +187,7 @@ export default function PodcastInlinePlayer({ podcast }: PodcastInlinePlayerProp
|
||||
{/* Hidden Audio Tag */}
|
||||
<audio
|
||||
ref={audioRef}
|
||||
src={podcast.audioUrl}
|
||||
src={getMediaUrl(podcast.audioUrl)}
|
||||
preload="none"
|
||||
onPlay={() => setIsPlaying(true)}
|
||||
onPause={() => setIsPlaying(false)}
|
||||
|
||||
@@ -4,6 +4,7 @@ import Image from "next/image";
|
||||
import { Sparkles } from "lucide-react";
|
||||
import { cn } from "../lib/utils";
|
||||
import { useSettingsStore } from "../lib/store/settingsStore";
|
||||
import { getMediaUrl } from "../lib/media";
|
||||
|
||||
interface SafeImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'src'> {
|
||||
src?: string;
|
||||
@@ -19,7 +20,7 @@ interface SafeImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>,
|
||||
}
|
||||
|
||||
export default function SafeImage({
|
||||
src,
|
||||
src: rawSrc,
|
||||
alt = "تصویر مکمل کنینا",
|
||||
className,
|
||||
imgClassName,
|
||||
@@ -34,6 +35,8 @@ export default function SafeImage({
|
||||
const [loading, setLoading] = React.useState(!priority);
|
||||
const logoUrl = useSettingsStore(state => state.getText('site_logo', ''));
|
||||
|
||||
const src = React.useMemo(() => getMediaUrl(rawSrc), [rawSrc]);
|
||||
|
||||
// Check if external domain is in allowed remote patterns or relative path
|
||||
const isExternal = typeof src === 'string' && (src.startsWith('http://') || src.startsWith('https://'));
|
||||
const isBlobOrData = typeof src === 'string' && (src.startsWith('blob:') || src.startsWith('data:'));
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
Sparkles,
|
||||
Loader2
|
||||
} from "lucide-react";
|
||||
import { getMediaUrl } from "../lib/media";
|
||||
|
||||
interface VideoModalPlayerProps {
|
||||
isOpen: boolean;
|
||||
@@ -317,8 +318,8 @@ export default function VideoModalPlayer({ isOpen, onClose, video }: VideoModalP
|
||||
>
|
||||
<video
|
||||
ref={videoRef}
|
||||
src={video.videoUrl}
|
||||
poster={video.thumbnail}
|
||||
src={getMediaUrl(video.videoUrl)}
|
||||
poster={getMediaUrl(video.thumbnail)}
|
||||
autoPlay
|
||||
playsInline
|
||||
onPlay={() => setIsPlaying(true)}
|
||||
|
||||
Reference in new issue
Block a user