title: No 'Access-Control-Allow-Origin' header is present.. angular 7 and express
body: <p>I am running a server with express at port 3000 and a client with angular 7 at port 4200. Once I make a request, I run into CORS issue.</p>
  
  <p>Access to XMLHttpRequest at '<a href="http://localhost:3000/drug" rel="nofollow noreferrer">http://localhost:3000/drug</a>' from origin '<a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.</p>
  
  <p>I have tried all the solutions online like using cors package, and setting the middleware before router like below codes (<a href="https://stackoverflow.com/questions/50448981/angular-6-no-access-control-allow-origin-header-is-present-on-the-requested">Angular 6 - No &#39;Access-Control-Allow-Origin&#39; header is present on the requested resource</a>). But it still is not solved and keep getting same errors. Does anyone have same problem that CORS is not solved with all the solutions? Could you please help me? </p>
  
  <pre><code>app.use((req, res, next) =&gt; {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
    res.header(
      "Access-Control-Allow-Header",
      "Origin, X-Requested-With, Content-Type, Accept"
    );
    next();
  });
  
  app.use((req, res, next) =&gt; {
        res.header("Access-Control-Allow-Origin", "http://localhost:4200");
        res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
        res.header(
          "Access-Control-Allow-Header",
          "Origin, X-Requested-With, Content-Type, Accept"
        );
        next();
      });
  </code></pre>