From 4fe9b4b3412a0d95bd4d3d6f325edbf930727274 Mon Sep 17 00:00:00 2001 From: nune <145225213+gigirassy@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:56:52 -0500 Subject: [PATCH] Update app.js --- app.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/app.js b/app.js index 7abe98d..3d541d7 100644 --- a/app.js +++ b/app.js @@ -7,7 +7,7 @@ const PORT = process.env.PORT || 3000; app.use(express.static('public')); // Route to fetch Pastebin raw text data using the Paste ID or URL -app.get('/:pasteId?', async (req, res) => { +app.get('/:pasteId?', (req, res) => { let rawUrl; // If the pasteId is provided directly in the URL (like /uxK7EPux) @@ -30,17 +30,8 @@ app.get('/:pasteId?', async (req, res) => { return res.status(400).json({ error: 'URL or Paste ID is required' }); } - 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 it's treated as plain text - res.send(text); // Send raw text - } catch (error) { - res.status(500).json({ error: error.message }); - } + // Perform the redirect to the raw Pastebin URL + res.redirect(rawUrl); }); // Start the server