Upload proxy-only.js
Browse files- proxy-only.js +71 -0
proxy-only.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Stremio Proxy Fallback
|
| 3 |
+
*
|
| 4 |
+
* This is a minimal server that mimics some of Stremio's endpoints just enough
|
| 5 |
+
* to allow testing whether the proxy setup works correctly in Hugging Face.
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
const http = require('http');
|
| 9 |
+
|
| 10 |
+
const PORT = 7860;
|
| 11 |
+
|
| 12 |
+
// Create a basic server
|
| 13 |
+
const server = http.createServer((req, res) => {
|
| 14 |
+
console.log(`Request received: ${req.method} ${req.url}`);
|
| 15 |
+
|
| 16 |
+
// Enable CORS for all requests
|
| 17 |
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
| 18 |
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
| 19 |
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
| 20 |
+
|
| 21 |
+
// Handle preflight requests
|
| 22 |
+
if (req.method === 'OPTIONS') {
|
| 23 |
+
res.writeHead(204);
|
| 24 |
+
res.end();
|
| 25 |
+
return;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
// Basic health check
|
| 29 |
+
if (req.url === '/health' || req.url === '/') {
|
| 30 |
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
| 31 |
+
res.end(JSON.stringify({
|
| 32 |
+
status: 'ok',
|
| 33 |
+
message: 'Stremio proxy-only mode is running',
|
| 34 |
+
timestamp: new Date().toISOString()
|
| 35 |
+
}));
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// Mock Stremio endpoints
|
| 40 |
+
if (req.url.startsWith('/manifest.json')) {
|
| 41 |
+
// Return a simple manifest
|
| 42 |
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
| 43 |
+
res.end(JSON.stringify({
|
| 44 |
+
id: 'org.stremio.minimal',
|
| 45 |
+
version: '1.0.0',
|
| 46 |
+
name: 'Stremio Minimal Proxy',
|
| 47 |
+
description: 'Minimal Stremio server for Hugging Face Spaces testing',
|
| 48 |
+
resources: ['catalog', 'meta', 'stream'],
|
| 49 |
+
types: ['movie', 'series'],
|
| 50 |
+
catalogs: []
|
| 51 |
+
}));
|
| 52 |
+
return;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
// Return a generic response for any other endpoint
|
| 56 |
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
| 57 |
+
res.end(JSON.stringify({
|
| 58 |
+
status: 'ok',
|
| 59 |
+
message: 'Stremio proxy-only mode',
|
| 60 |
+
endpoint: req.url,
|
| 61 |
+
info: 'This is a fallback mode that mimics Stremio endpoints for testing'
|
| 62 |
+
}));
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
// Start the server
|
| 66 |
+
server.listen(PORT, () => {
|
| 67 |
+
console.log(`===== Stremio Proxy-Only Mode =====`);
|
| 68 |
+
console.log(`Server running on port ${PORT}`);
|
| 69 |
+
console.log(`This is a FALLBACK server that doesn't provide real Stremio functionality`);
|
| 70 |
+
console.log(`Use it only to verify your deployment is working correctly`);
|
| 71 |
+
});
|