score:1

Accepted answer

because you have the proxy specified in your package.json, when you make the request from the client to the server, you want to leave off the origin part of the url.

this should be changed to

  componentdidmount() {
    fetch('http://localhost:8080/xxxx')
      .then(response => response.json())
      .then(xxxx=> this.setstate({ xxxx }, () => console.log("successfully fetched xxxx", xxxx)));
  }

this

    fetch('/xxxx')
      .then(response => response.json())
      .then(xxxx=> this.setstate({ xxxx }, () => console.log("successfully fetched xxxx", xxxx)));
  }

essentially you will only specify the actual endpoint and leave the origin off, this will now allow webpack dev server to proxy your request to your express server.

score:0

chaim's answer above worked! thanks


Related Query

More Query from same tag