mp4

// server.js // Usage: set RAPIDAPI_KEY in .env or environment, then: node server.js const express = require(‘express’); const axios = require(‘axios’); const cors = require(‘cors’); require(‘dotenv’).config(); const app = express(); app.use(cors()); app.use(express.json()); const RAPIDAPI_HOST = ‘instagram-downloader-download-instagram-videos-stories.p.rapidapi.com’; const RAPIDAPI_URL = `https://${RAPIDAPI_HOST}/index`; app.post(‘/api/getmp4’, async (req, res) => { try { const { url } = req.body; if (!url) return res.status(400).json({ error: ‘Missing url in body’ }); const r = await axios.get(RAPIDAPI_URL, { params: { url }, headers: { ‘x-rapidapi-key’: process.env.RAPIDAPI_KEY, ‘x-rapidapi-host’: RAPIDAPI_HOST }, timeout: 20000 }); // Return upstream response JSON directly for the frontend to parse res.json(r.data); } catch (err) { console.error(‘API error:’, err.response?.data || err.message); res.status(500).json({ error: ‘Failed to fetch’, details: err.response?.data || err.message }); } }); const PORT = process.env.PORT || 3000; app.listen(PORT, () => console.log(`Proxy running on http://localhost:${PORT}`));

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post