Improve video sharing by using cached data instead of live API calls

Modify the video share endpoint in routes.ts to retrieve video data from the cache using `storage.getVideos()` instead of making direct API calls with `findVideoByAnyId` and `storage.getVideo()`, which was causing 404 errors. This ensures that share links correctly resolve video details and metadata.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 401e2ec0-e00d-4f10-9d0e-60f3d479f9a5
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 112fcbe4-f903-4480-927e-8bcf6e744878
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/60d372ff-2c10-46c7-b01b-10c3435136b0/401e2ec0-e00d-4f10-9d0e-60f3d479f9a5/Ufka13F
This commit is contained in:
sebastjanartic 2026-01-09 17:07:40 +00:00
parent aba0ce70f8
commit 9de621d409

View File

@ -1284,7 +1284,19 @@ export async function registerRoutes(app: Express): Promise<Server> {
app.get('/share/video/:id', async (req, res) => {
try {
const { id } = req.params;
const video = await findVideoByAnyId(id);
// Find video from cache (not direct Bunny API to avoid 404 errors)
const allVideos = await storage.getVideos(600, 0);
let video;
// Check if it's a full UUID or short ID
if (id.length === 36 && id.includes('-')) {
video = allVideos.find(v => v.id === id);
} else if (id.length === 8) {
video = allVideos.find(v => v.id.replace(/-/g, '').substring(0, 8) === id);
} else {
video = allVideos.find(v => v.id.includes(id));
}
if (!video) {
return res.status(404).send('Video not found');