quick / frontend /app /api /_proxy.js
FredyHoundayi's picture
Hardcode HF Space backend URL — no env var needed
3bd432c
raw
history blame contribute delete
800 Bytes
const BACKEND = 'https://fredyhoundayi-quick.hf.space';
/**
* Proxy a request to the FastAPI backend.
* @param {string} path - Backend path (e.g. "/build")
* @param {RequestInit} options - Fetch options (method, headers, body)
* @returns {Promise<Response>}
*/
export async function proxyRequest(path, options = {}) {
const url = `${BACKEND}${path}`;
try {
const res = await fetch(url, options);
const body = await res.text();
return new Response(body, {
status: res.status,
headers: { 'Content-Type': res.headers.get('Content-Type') || 'application/json' },
});
} catch (err) {
return new Response(JSON.stringify({ detail: `Backend unreachable: ${err.message}` }), {
status: 503,
headers: { 'Content-Type': 'application/json' },
});
}
}