hi i am making a netlify edge function as an endpoint and i do not get full data when request. Below is my code.
export default async (request: Request) => {
const url = new URL(request.url);
const outputUrl = url.searchParams.get("with");
if (!outputUrl) {
return new Response("Missing 'with' query parameter", { status: 400 });
}
try {
const fetchData = await fetch(outputUrl);
if (!fetchData.ok) {
return new Response(`Failed to fetch resource: ${fetchData.statusText}`, {
status: fetchData.status,
});
}
const body = await fetchData.arrayBuffer();
const headers = new Headers(fetchData.headers);
headers.set("Access-Control-Allow-Origin", "*");
headers.set("Cache-Control", "public, max-age=31536000, s-maxage=31536000");
headers.set(
"Netlify-CDN-Cache-Control",
"public, max-age=31536000, s-maxage=31536000"
);
return new Response(body, {
status: fetchData.status,
headers,
});
} catch (error) {
return new Response(`Error fetching data: ${error.message}`, {
status: 500,
});
}
};
export const config = { cache: "manual", path: "/api" };
all my response very small (incompelete) like (original size is 160k and it return 820b) with netlify edge cache hit.