title: CORS POST request blocked in EXPRESS & REACT on hosting & domain
body: <p>I'm using express CORS module &amp; react AXIOS on my host &amp; domain.</p>
  
  <p>I defined <code>CORS()</code> in my route middleware, and the GET request worked perfectly.</p>
  
  <p>but for POST &amp; PUT requests still, the Access-Control-Allow-Origin BLOCKED error displays.</p>
  
  <p>ALSO I'm using webpack and dev server to proxy front end react</p>
  
  <p>This is my express <code>server.js</code> file</p>
  
  <pre class="lang-js prettyprint-override"><code>const express = require("express");
  const app = express();
  
  const db = require("./config/db");
  db.connect(() =&gt; {
    console.log(`Postgres connected`);
  });
  // Middlewares
  
  // CORS
  const cors = require("cors");
  app.use(cors(
      {
      origin: http://asia-sarmaye.ir
  }));
  // BodyParsing
  var bodyParser = require("body-parser");
  app.use(
    bodyParser.urlencoded({
      extended: false
    })
  );
  app.use(bodyParser.json());
  // Router
  app.use("/api", cors(), require("./routes/dum"));
  
  // Listening
  const port = 4000;
  app.listen(port, () =&gt; {
    console.log(`Listening on port ${port}`);
  });
  
  </code></pre>
  
  <p>And this is REACT axios POST request</p>
  
  <pre class="lang-js prettyprint-override"><code>axios
            .post(
              "http://api.asia-sarmaye.ir/api/user",
              {
                headers: { "Access-Control-Allow-Origin": "*" }
              },
              data,
              res =&gt; {
                console.log(res.data);
              }
            )
  </code></pre>
  
  <p>any idea how to fix this?</p>