title: 502 error sending post request to app running on ngrok
body: <p>I have a react front end app that I am running locally with ngrok and from this I am trying to send a fetch post request to the server that I have added to the project - react app contained within client folder and the express server contained within server folder.</p>
  
  <p>So the client fetch post request does hit the server endpoint as it consoles the empty body and on the ngrok it says POST / but doesnt give a status!? . Yet in the front-end it gives a bad request 502 error and a CORS error, I have tried enabling CORS on both sides:</p>
  
  <p>here is the code (the consoles work): </p>
  
  <p>Client: </p>
  
  <pre><code>  storeEmailData(domain, emailAddress, email, storeName) {
  
  console.log('consoling the data IN API FILE' + domain);
  console.log('consoling the data IN API FILE' + emailAddress);
  fetch('https://3ecec55f.ngrok.io/', { 
    method: 'POST',
    mode: 'cors',
    data: {
      domain: domain,
      emailAddress: emailAddress,
      email: email,
      storeName: storeName,
  
    }
  
  }, {mode: 'cors'} )
  
  .then(function(response) {
    console.log('response' + response);
  }).then(function(body) {
    console.log(body);
  });
  }
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>var app = express();
  var db = require('./data_db.js')
  var cors = require('cors');
  app.use(cors());
  var bodyParser = require('body-parser')
  
  app.use(bodyParser.json())
  
  app.post('/', function (req, res) {
     console.log('the data' + JSON.stringify(req.body))
  
  
  });
  </code></pre>
  
  <p>So the server just consoles an empty body.
  Here within the front-end are the errors:</p>
  
  <pre><code>api.js:25 POST https://3ecec55f.ngrok.io/ 502 (Bad 
  Gateway)
  storeEmailData @ api.js:25
  ReturnsSettings._this.saveDetails @ ReturnsSettings.js:45
  onClick @ ReturnsSettings.js:66
  settings:1 Access to fetch at 'https://3ecec55f.ngrok.io/' 
  from origin 'https://c2bca71d.ngrok.io' has been blocked 
  by CORS policy: No 'Access-Control-Allow-Origin' header is 
  present on the requested resource. If an opaque response 
  serves your needs, set the request's mode to 'no-cors' to 
  fetch the resource with CORS disabled.
  settings:1 Uncaught (in promise) TypeError: Failed to 
  fetch
  </code></pre>
  
  <p>any help would be greatly appreciated, thanks!!</p>