From ac8b31dbe376fd33e43f2cdbd2b959ca3a4c8dc4 Mon Sep 17 00:00:00 2001 From: Deepak Kapoor <41769111+orthdron@users.noreply.github.com> Date: Wed, 14 Aug 2024 03:05:11 -0400 Subject: [PATCH] Bug fixes (#19) * minor bugfixes --- app/(default)/(authorized)/videos/page.tsx | 2 +- app/(default)/(public)/video/[id]/page.tsx | 4 ++-- app/embed/[id]/page.tsx | 4 ++-- components/video/VideoThumbnail.tsx | 2 +- lib/s3.ts | 5 +++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/(default)/(authorized)/videos/page.tsx b/app/(default)/(authorized)/videos/page.tsx index 70a1a4c..66e3311 100644 --- a/app/(default)/(authorized)/videos/page.tsx +++ b/app/(default)/(authorized)/videos/page.tsx @@ -23,7 +23,7 @@ export default async function MyVideos() { .where('userId', '=', user.id) .execute(); - const publicUrl = process.env.PROCESSED_VIDEO_URL; + const publicUrl = process.env.PROCESSED_VIDEO_URL!.replace(/\/+$/, ''); if (!publicUrl) { throw new Error("PROCESSED_VIDEO_URL is not defined"); diff --git a/app/(default)/(public)/video/[id]/page.tsx b/app/(default)/(public)/video/[id]/page.tsx index 0891c1c..0eec1a8 100644 --- a/app/(default)/(public)/video/[id]/page.tsx +++ b/app/(default)/(public)/video/[id]/page.tsx @@ -32,7 +32,7 @@ export default async function Page({ params }: { params: { id: string } }) { redirect('/'); } - const publicUrl = process.env.PROCESSED_VIDEO_URL; + const publicUrl = process.env.PROCESSED_VIDEO_URL!.replace(/\/+$/, ''); if (!publicUrl) { throw new Error("PROCESSED_VIDEO_URL is not defined"); } @@ -40,7 +40,7 @@ export default async function Page({ params }: { params: { id: string } }) { const videoProps = { url: `${publicUrl}/${id}/master.m3u8`, vtt: `${publicUrl}/${id}/sprite.vtt`, - poster: `${publicUrl}/${id}/poster.jpeg`, + poster: `${publicUrl}/${id}/poster.jpg`, ...video }; diff --git a/app/embed/[id]/page.tsx b/app/embed/[id]/page.tsx index 285ea81..092b4b6 100644 --- a/app/embed/[id]/page.tsx +++ b/app/embed/[id]/page.tsx @@ -29,7 +29,7 @@ export default async function Page({ params }: { params: { id: string } }) { redirect('/'); } - const publicUrl = process.env.PROCESSED_VIDEO_URL; + const publicUrl = process.env.PROCESSED_VIDEO_URL!.replace(/\/+$/, ''); if (!publicUrl) { throw new Error("PROCESSED_VIDEO_URL is not defined"); } @@ -37,7 +37,7 @@ export default async function Page({ params }: { params: { id: string } }) { const videoProps = { url: `${publicUrl}/${id}/master.m3u8`, vtt: `${publicUrl}/${id}/sprite.vtt`, - poster: `${publicUrl}/${id}/poster.jpeg`, + poster: `${publicUrl}/${id}/poster.jpg`, ...video }; diff --git a/components/video/VideoThumbnail.tsx b/components/video/VideoThumbnail.tsx index 8fa80cc..ac96d56 100644 --- a/components/video/VideoThumbnail.tsx +++ b/components/video/VideoThumbnail.tsx @@ -3,7 +3,7 @@ import VideoThumbnailHover from "./videoThumbnailHover"; export default function VideoThumbnail({ video }: { video: { id: string; title: string } }) { const { id, title } = video; - const baseUrl = process.env.PROCESSED_VIDEO_URL!; + const baseUrl = process.env.PROCESSED_VIDEO_URL!.replace(/\/+$/, ''); return ( diff --git a/lib/s3.ts b/lib/s3.ts index 6a81aac..557cbf9 100644 --- a/lib/s3.ts +++ b/lib/s3.ts @@ -21,9 +21,10 @@ export function createS3Client() { }, forcePathStyle: true, region: region, - endpoint: endpoint }; - + if (endpoint) { + s3ClientConfig.endpoint = endpoint; + } // Create and return the S3 client const s3client = new S3Client(s3ClientConfig);