Skip to content

Commit c97206f

Browse files
committed
Attempt to reference media properly
1 parent eeb6c08 commit c97206f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

functions/media/[[all]].js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export async function onRequestGet(ctx) {
2+
const path = new URL(ctx.request.url).pathname.replace("/media/", "");
3+
const file = await ctx.env.MEDIA.get(path);
4+
if (!file) return new Response(null, { status: 404 });
5+
return new Response(file.body, {
6+
headers: { "Content-Type": file.httpMetadata.contentType },
7+
});
8+
}

src/app/contents.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"deathdate": "",
162162
"images": [
163163
"https://i.imgur.com/7Z5UHr3.jpg",
164-
"https://pub-de0e381b0f7043a297494a2012c5777f.r2.dev/PixieHappyCountertop.mp4"
164+
"/media/PixieHappyCountertop.mp4"
165165
],
166166
"imageAlt": "Images of Pixie the cat",
167167
"sounds": [

0 commit comments

Comments
 (0)