feat: implement a Dart web server with API routing, static file serving, Xtream proxy, and authentication.

This commit is contained in:
Michael committed 2025-12-06 10:15:41 +01:00
1 parent 1d157bcc75
commit b2bfc56021
1 file changed
+13 -3
+13 -3
View File
@@ -153,16 +153,26 @@ Handler _createXtreamProxyHandler() {
print('Proxying request to: $targetUrl');
// Use simple http.get/post with timeout
// Headers to simulate a legitimate IPTV client
// Many IPTV servers check User-Agent and Referer to prevent unauthorized access
final proxyHeaders = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.9',
'Referer': baseUrl,
'Origin': baseUrl,
};
// Use simple http.get/post with timeout and proper headers
http.Response response;
if (request.method == 'GET') {
response = await http.get(targetUrl).timeout(
response = await http.get(targetUrl, headers: proxyHeaders).timeout(
const Duration(seconds: 30),
onTimeout: () => http.Response('Request timeout', 504),
);
} else if (request.method == 'POST') {
final body = await request.readAsString();
response = await http.post(targetUrl, body: body).timeout(
response = await http.post(targetUrl, headers: proxyHeaders, body: body).timeout(
const Duration(seconds: 30),
onTimeout: () => http.Response('Request timeout', 504),
);