-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-proxy.js
More file actions
32 lines (29 loc) · 1.2 KB
/
Copy pathdebug-proxy.js
File metadata and controls
32 lines (29 loc) · 1.2 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
const fetch = require('node-fetch'); // actually standard fetch is available in Node 18+, but let's see.
// If node < 18, we might have issues. using https module is safer if no dependencies.
const https = require('https');
const url = 'https://api.allorigins.win/get?url=' + encodeURIComponent('https://sportex-lac.vercel.app/');
https.get(url, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
try {
const json = JSON.parse(data);
console.log("Status Code:", json.status ? json.status.http_code : 'unknown');
console.log("Content Length:", json.contents ? json.contents.length : 0);
if (json.contents) {
console.log("--- HTML CONTENT PREVIEW ---");
console.log(json.contents.substring(0, 1000));
console.log("--- HTML CONTENT END ---");
} else {
console.log("No contents found in response");
}
} catch (e) {
console.error("Error parsing JSON:", e);
console.log("Raw Data:", data);
}
});
}).on('error', (err) => {
console.error("Error fetching:", err.message);
});