const express = require('express'); const fetch = require('node-fetch'); const cookieParser = require('cookie-parser'); const app = express(); const PORT = process.env.PORT || 3000; app.use(express.static('public')); app.use(cookieParser()); const autoCopyDefault = process.env.AUTO_COPY_DEFAULT === 'false'; app.get('/auto-copy-default', (req, res) => { res.json({ autoCopyDefault }); }); // Route to handle raw Pastebin requests app.get('/:pasteId', async (req, res) => { const pasteId = req.params.pasteId; const rawUrl = `https://pastebin.com/raw/${pasteId}`; try { const response = await fetch(rawUrl); if (!response.ok) { throw new Error('Failed to fetch data from Pastebin'); } const text = await response.text(); res.setHeader('Content-Type', 'text/plain'); // Ensure raw text response res.send(text); // Send the raw paste content } catch (error) { res.status(500).json({ error: error.message }); // Return error in JSON format } }); // Start the server app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); });