File size: 773 Bytes
f6522be | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /**
* Vercel Serverless Function: /api/status
* Health check proxied to Hugging Face backend
*/
export default async function handler(req, res) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With');
if (req.method === 'OPTIONS') {
return res.status(204).end();
}
try {
const hfRes = await fetch('https://ilhamdev-quote-api.hf.space/status');
const text = await hfRes.text();
res.setHeader('Content-Type', 'application/json');
return res.status(hfRes.status).send(text);
} catch (err) {
return res.status(502).json({ status: false, message: 'Backend unreachable' });
}
}
|