Background logs

This commit is contained in:
muzam1l
2022-04-13 16:59:02 +05:30
parent 46e6927c68
commit a33a3eb6e2
5 changed files with 121 additions and 52 deletions

19
pages/api/proxy.ts Normal file
View File

@@ -0,0 +1,19 @@
import type { NextApiRequest, NextApiResponse } from 'next'
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
try {
const { url, opts } = req.body
console.log(url)
const r = await fetch(url, opts);
if (!r.ok) throw (r.statusText)
const data = await r.json()
return res.json(data)
} catch (error) {
console.warn(error)
return res.status(500).json({ message: "Something went wrong!" })
}
}