Sakky1/bingo
0
1'use server'2 3import { NextApiRequest, NextApiResponse } from 'next'4import { fetch } from '@/lib/isomorphic'5 6export default async function handler(req: NextApiRequest, res: NextApiResponse) {7 try {8 const { url, headers, method = 'GET', body } = req.body9 if (!url) {10 return res.end('ok')11 }12 const response = await fetch(url, { headers, method, body, redirect: 'manual' })13 const text = await response.text()14 res.writeHead(200, {15 'Content-Type': 'application/text',16 'x-url': response.url,17 'x-status': response.status,18 })19 res.end(text)20 } catch (e) {21 console.log(e)22 return res.end(e)23 }24}25 