solbass
solbass
CDCloudflare Developers
Created by solbass on 9/26/2024 in #pages-help
UNEXPECTED END OF JSON
Hi, Whenever I make API calls through my next js server hosted on cloudflare pages, I am constantly receiving the error Unexpected end of JSON input when reading await response.json(). I dont know if my servers are being overwhelemed, the api request always works because im testing it on postman. There is something going on, when sending requests from the api. For more info, the request is being sent to my external heroku server. any ideas?
14 replies
CDCloudflare Developers
Created by solbass on 8/30/2024 in #general-help
Next js server request body empty some times
Sometimes when making a request, the request body is working fine and sometimes the body is empty. I know my api is fine because i tested it a lot with postman I found that if I put req.clone and await clone.text() the response body always returns even though I am not doing anything with the clone I just added that code This is nextjs api server request any ideas??
const res = await fetch(forwardUrl, {
...req,
headers: forwardHeaders,
method: req.method,
// body: req.method !== "GET" ? body : null,
body: body ? JSON.stringify(body) : null,
cache: "no-store",
// @ts-ignore
// duplex: "half",
});

// console.log("Response Status", res.status);
// console.log("Response Type", res.type);
// console.log("Response Content Length", res.headers.get("Content-Length"));
// console.log("Response Content Type", res.headers.get("Content-Type"));

// // Clone the response for inspection or logging
// const clone = res.clone();

// // Use the clone to read the body for logging or other processing
// await clone.text(); // or clone.json() if expecting JSON

return new Response(res.body, {
status: res.status,
});
const res = await fetch(forwardUrl, {
...req,
headers: forwardHeaders,
method: req.method,
// body: req.method !== "GET" ? body : null,
body: body ? JSON.stringify(body) : null,
cache: "no-store",
// @ts-ignore
// duplex: "half",
});

// console.log("Response Status", res.status);
// console.log("Response Type", res.type);
// console.log("Response Content Length", res.headers.get("Content-Length"));
// console.log("Response Content Type", res.headers.get("Content-Type"));

// // Clone the response for inspection or logging
// const clone = res.clone();

// // Use the clone to read the body for logging or other processing
// await clone.text(); // or clone.json() if expecting JSON

return new Response(res.body, {
status: res.status,
});
4 replies
CDCloudflare Developers
Created by solbass on 8/30/2024 in #pages-help
Fetch 200 but response body empty
Sometimes when making a request, the request body is working fine and sometimes the body is empty. I know my api is fine because i tested it a lot with postman I found that if I put req.clone and await clone.text() the response body always returns even though I am not doing anything with the clone I just added that code This is nextjs api server request any ideas??
const res = await fetch(forwardUrl, {
...req,
headers: forwardHeaders,
method: req.method,
// body: req.method !== "GET" ? body : null,
body: body ? JSON.stringify(body) : null,
cache: "no-store",
// @ts-ignore
// duplex: "half",
});

// console.log("Response Status", res.status);
// console.log("Response Type", res.type);
// console.log("Response Content Length", res.headers.get("Content-Length"));
// console.log("Response Content Type", res.headers.get("Content-Type"));

// // Clone the response for inspection or logging
// const clone = res.clone();

// // Use the clone to read the body for logging or other processing
// await clone.text(); // or clone.json() if expecting JSON

return new Response(res.body, {
status: res.status,
});
const res = await fetch(forwardUrl, {
...req,
headers: forwardHeaders,
method: req.method,
// body: req.method !== "GET" ? body : null,
body: body ? JSON.stringify(body) : null,
cache: "no-store",
// @ts-ignore
// duplex: "half",
});

// console.log("Response Status", res.status);
// console.log("Response Type", res.type);
// console.log("Response Content Length", res.headers.get("Content-Length"));
// console.log("Response Content Type", res.headers.get("Content-Type"));

// // Clone the response for inspection or logging
// const clone = res.clone();

// // Use the clone to read the body for logging or other processing
// await clone.text(); // or clone.json() if expecting JSON

return new Response(res.body, {
status: res.status,
});
1 replies
CDCloudflare Developers
Created by solbass on 5/21/2024 in #pages-help
build exceeded memory
My latest next js site's build is facing this error "Failed: build exceeded memory limit and was terminated" And I'm on the paid plan for workers and pages please help, site down 😟
1 replies
CDCloudflare Developers
Created by solbass on 2/26/2024 in #general-help
Git Integration Next JS Cloudflare pages
No description
9 replies
CDCloudflare Developers
Created by solbass on 2/21/2024 in #general-help
┬ Waiting for DNS to propagate (19s) ...
No description
8 replies