stream / proxy-only.js
y59's picture
Upload proxy-only.js
84fbefb verified
/**
* 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`);
});