const express = require('express'); const fetch = require('isomorphic-fetch'); const bodyParser = require('body-parser'); const { HttpProxyAgent } = require('http-proxy-agent'); const http = require('http'); const https = require('https'); const app = express(); const port = 7860; app.use(bodyParser.json()); app.post('/fetch', async (req, res) => { const { url, options } = req.body; try { if (options.agent) { const agentConfig = options.agent; if (agentConfig.proxy) { options.agent = new HttpProxyAgent(agentConfig.proxy); } else { options.agent = url.startsWith('http://') ? new http.Agent(agentConfig) : new https.Agent(agentConfig); } } const response = await fetch(url, options); res.json({ status: response.status }); console.info(`${url} is UP`); } catch (error) { console.error('Fetch error:', error); res.status(500).json({ error: 'Fetch error', message: error.message }); } }); app.listen(port, () => { console.log(`Server is running on http://localhost:${port}`); });