-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.js
More file actions
37 lines (31 loc) · 839 Bytes
/
Copy pathworker.js
File metadata and controls
37 lines (31 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export default {
async fetch(request) {
const url = new URL(request.url)
const id = url.searchParams.get("id")
if (!id) {
return new Response("Missing ?id=VIDEO_ID", {
status: 400,
headers: { "Cache-Control": "no-store" }
})
}
const api = `https://pipedapi.kavin.rocks/streams/${id}`
const res = await fetch(api, {
headers: {
"User-Agent": "Mozilla/5.0"
}
})
if (!res.ok) {
return new Response("Failed to fetch streams", {
status: 500,
headers: { "Cache-Control": "no-store" }
})
}
const data = await res.json()
return new Response(JSON.stringify(data), {
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-store"
}
})
}
}