podcast manager
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 35 lines 1.1 kB view raw
1import {RequestHandler} from 'express' 2 3export const corsProxy: RequestHandler = async (req, res) => { 4 const url = req.query.url 5 if (typeof url !== 'string' || !url) { 6 res.status(400).json({error: 'Missing or invalid url parameter'}) 7 return 8 } 9 10 try { 11 const response = await fetch(url, { 12 headers: { 13 'User-Agent': 'Mozilla/5.0 (compatible; Skypod/1.0; +https://skypod.accidental.cc)', 14 }, 15 }) 16 17 if (!response.ok) { 18 res.status(response.status).json({error: `Failed to fetch feed: ${response.statusText}`}) 19 return 20 } 21 22 const contentType = response.headers.get('content-type') || 'application/xml' 23 const content = await response.text() 24 25 res.setHeader('Content-Type', contentType) 26 res.setHeader('Cache-Control', 'public, max-age=300') // 5 min cache 27 res.send(content) 28 } catch (error) { 29 console.error('Feed proxy error:', error) 30 res.status(500).json({ 31 error: 'Failed to fetch feed', 32 message: error instanceof Error ? error.message : 'Unknown error', 33 }) 34 } 35}