Spaces:
Sleeping
Sleeping
Update index.js
Browse files
index.js
CHANGED
@@ -31,37 +31,22 @@ app.get('*', async (req, res) => {
|
|
31 |
const filename = req.params[0];
|
32 |
|
33 |
if (filename) {
|
34 |
-
const originalUrl = `${REQUEST_URL
|
35 |
const headers = {
|
36 |
'Authorization': `Bearer ${TOKEN}`,
|
37 |
'Range': req.headers.range || ''
|
38 |
};
|
39 |
|
40 |
try {
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
newResponse.headers.delete('Cf-Ray');
|
51 |
-
newResponse.headers.delete('Report-To');
|
52 |
-
newResponse.headers.delete('X-Amz-Cf-Id');
|
53 |
-
newResponse.headers.delete('X-Amz-Cf-Pop');
|
54 |
-
newResponse.headers.delete('X-Amz-Server-Side-Encryption');
|
55 |
-
newResponse.headers.delete('X-Amz-Storage-Class');
|
56 |
-
newResponse.headers.delete('X-Cache');
|
57 |
-
newResponse.headers.set('Cache-Control', 'private, max-age=21188');
|
58 |
-
newResponse.headers.set('Connection', 'close');
|
59 |
-
newResponse.headers.set('Server', 'gvs 1.0');
|
60 |
-
newResponse.headers.set('Vary', 'Origin');
|
61 |
-
newResponse.headers.set('X-Content-Type-Options', 'nosniff');
|
62 |
-
newResponse.headers.set('Access-Control-Allow-Origin', '*');
|
63 |
-
|
64 |
-
res.send(newResponse);
|
65 |
} catch (err) {
|
66 |
console.error(err);
|
67 |
return res.status(500).send('500');
|
|
|
31 |
const filename = req.params[0];
|
32 |
|
33 |
if (filename) {
|
34 |
+
const originalUrl = REQUEST_URL ? `${REQUEST_URL}${filename}` : `https://huggingface.co/tranquan24/video/resolve/main/${filename}`;
|
35 |
const headers = {
|
36 |
'Authorization': `Bearer ${TOKEN}`,
|
37 |
'Range': req.headers.range || ''
|
38 |
};
|
39 |
|
40 |
try {
|
41 |
+
request.get({ url: originalUrl, headers: headers }, (err, response, body) => {
|
42 |
+
if (err) {
|
43 |
+
console.error(err);
|
44 |
+
return res.status(500).send('500');
|
45 |
+
}
|
46 |
+
|
47 |
+
res.set(response.headers);
|
48 |
+
res.status(response.statusCode).send(body);
|
49 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
} catch (err) {
|
51 |
console.error(err);
|
52 |
return res.status(500).send('500');
|