From 132103860992316b6bed15e2134e82c2fd54160e Mon Sep 17 00:00:00 2001
From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com>
Date: Mon, 4 Aug 2025 19:48:38 +0000
Subject: [PATCH] Improve video loading and display with error handling and
updated headers
Improves thumbnail loading in VideoCard component with error handling and updates response headers in /thumbnail route.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 50814a1e-92e4-4968-856f-7bc7eedf5e8f
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/50814a1e-92e4-4968-856f-7bc7eedf5e8f/WNLqOHv
---
client/src/components/video-card.tsx | 24 ++++++++++++------------
server/routes.ts | 3 ++-
test.svg | 25 +++++++++++++++++++++++++
3 files changed, 39 insertions(+), 13 deletions(-)
create mode 100644 test.svg
diff --git a/client/src/components/video-card.tsx b/client/src/components/video-card.tsx
index 375eb4a..fb22be8 100644
--- a/client/src/components/video-card.tsx
+++ b/client/src/components/video-card.tsx
@@ -61,20 +61,20 @@ export default function VideoCard({ video, onClick, onShare }: VideoCardProps) {
alt={video.title}
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"
data-testid={`img-thumbnail-${video.id}`}
+ onLoad={() => {
+ console.log('Thumbnail loaded successfully:', video.thumbnailUrl);
+ }}
onError={(e) => {
- // Create video preview iframe as fallback if thumbnail fails
+ console.error('Thumbnail failed to load:', video.thumbnailUrl);
+ // Use a data URL SVG as fallback
const target = e.target as HTMLImageElement;
- const container = target.parentElement;
- if (container) {
- container.innerHTML = `
-
- `;
- }
+ const fallbackSvg = `
+
+ `;
+ target.src = 'data:image/svg+xml;base64,' + btoa(fallbackSvg);
}}
/>
diff --git a/server/routes.ts b/server/routes.ts
index cadf4bd..60cd1d6 100644
--- a/server/routes.ts
+++ b/server/routes.ts
@@ -167,8 +167,9 @@ export async function registerRoutes(app: Express): Promise {
`;
- res.setHeader('Content-Type', 'image/svg+xml');
+ res.setHeader('Content-Type', 'image/svg+xml; charset=utf-8');
res.setHeader('Cache-Control', 'public, max-age=86400');
+ res.setHeader('Access-Control-Allow-Origin', '*');
res.send(svg);
} catch (error) {
diff --git a/test.svg b/test.svg
new file mode 100644
index 0000000..7762322
--- /dev/null
+++ b/test.svg
@@ -0,0 +1,25 @@
+
+
+
\ No newline at end of file