Nextjs and strapi - TypeError: fetch failed

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:


I have used Strapi before with NextJS 12, but having started using 13 I keep encountering a TypeError: fetch failed.

The below is the code for the page where I want to display the API data. I have a commented out res from a placeholder site; this works fine. The issue lies with the request from Strapi. I can get a positive response from Postman and Thunder Client, but still get the fetch failed every time.

async function getDataFrom() {
  // const res = await fetch("");
  const res = await fetch("http://localhost:1337/api/services/1");
  return res.json();

async function page() {
  const data = await getDataFrom();
  return (
    <div className=" bg-gray-200">
      <h1>API STUFF</h1>
      { => {
        return <div>{item.title}</div>;

The below is my middlewares.js file

module.exports = [
    name: "strapi::cors",
    resolve: "strapi::cors",
    config: {
      origin: "*",
      methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
      headers: ["Content-Type", "Authorization"],
      expose: ["Content-Range", "X-Content-Range"],
      credentials: true,
      maxAge: 86400,

Any advice would be gratefully received, thanks.

No asnwer is there for the err
but you must replace the fetch("http://localhost:1337/api/services/1") to fetch("http://YOUR IP ADDRESS:1337/api/services/1");

This is probably a little late but for anybody else who comes past here like I did in frustration, replace http://localhost:1337 with

thanks, that works