File size: 2,175 Bytes
ead0236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
70
71
/**
 * Stremio Proxy Fallback
 * 
 * This is a minimal server that mimics some of Stremio's endpoints just enough
 * to allow testing whether the proxy setup works correctly in Hugging Face.
 */

const http = require('http');

const PORT = 7860;

// Create a basic server
const server = http.createServer((req, res) => {
  console.log(`Request received: ${req.method} ${req.url}`);

  // Enable CORS for all requests
  res.setHeader('Access-Control-Allow-Origin', '*');
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
  res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
  
  // Handle preflight requests
  if (req.method === 'OPTIONS') {
    res.writeHead(204);
    res.end();
    return;
  }

  // Basic health check
  if (req.url === '/health' || req.url === '/') {
    res.writeHead(200, { 'Content-Type': 'application/json' });
    res.end(JSON.stringify({
      status: 'ok',
      message: 'Stremio proxy-only mode is running',
      timestamp: new Date().toISOString()
    }));
    return;
  }

  // Mock Stremio endpoints
  if (req.url.startsWith('/manifest.json')) {
    // Return a simple manifest
    res.writeHead(200, { 'Content-Type': 'application/json' });
    res.end(JSON.stringify({
      id: 'org.stremio.minimal',
      version: '1.0.0',
      name: 'Stremio Minimal Proxy',
      description: 'Minimal Stremio server for Hugging Face Spaces testing',
      resources: ['catalog', 'meta', 'stream'],
      types: ['movie', 'series'],
      catalogs: []
    }));
    return;
  }
  
  // Return a generic response for any other endpoint
  res.writeHead(200, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    status: 'ok',
    message: 'Stremio proxy-only mode',
    endpoint: req.url,
    info: 'This is a fallback mode that mimics Stremio endpoints for testing'
  }));
});

// Start the server
server.listen(PORT, () => {
  console.log(`===== Stremio Proxy-Only Mode =====`);
  console.log(`Server running on port ${PORT}`);
  console.log(`This is a FALLBACK server that doesn't provide real Stremio functionality`);
  console.log(`Use it only to verify your deployment is working correctly`);
});