-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathindex.js
More file actions
67 lines (58 loc) · 1.68 KB
/
Copy pathindex.js
File metadata and controls
67 lines (58 loc) · 1.68 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2024 iiPython
// List of domains
// Would of preferred to use JSON, but CF doesn't allow `require("fs")`
const domains = [
"apis",
"assetdelivery",
"avatar",
"badges",
"catalog",
"chat",
"contacts",
"contentstore",
"develop",
"economy",
"economycreatorstats",
"followings",
"friends",
"games",
"groups",
"groupsmoderation",
"inventory",
"itemconfiguration",
"locale",
"notifications",
"points",
"presence",
"privatemessages",
"publish",
"search",
"thumbnails",
"trades",
"translations",
"users"
]
// Export our request handler
export default {
async fetch(request) {
const url = new URL(request.url);
const path = url.pathname.split(/\//);
if (!path[1].trim())
return new Response(JSON.stringify({ message: "Missing ROBLOX subdomain." }), { status: 400 });
if (!domains.includes(path[1]))
return new Response(JSON.stringify({ message: "Specified subdomain is not allowed." }), { status: 401 });
const headers = new Headers(request.headers);
headers.delete("host");
headers.delete("roblox-id");
headers.delete("user-agent");
headers["user-agent"] = "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36";
const init = {
method: request.method,
headers,
};
if (request.method !== "GET" && request.method !== "HEAD") {
init.body = await request.text();
}
return fetch(`https://${path[1]}.roblox.com/${path.slice(2).join("/")}${url.search}`, init);
}
};