title: Access to XMLHttpRequest at 'http://localhost:3000/framework/create' from origin 'http://localhost:4200' has been blocked by CORS policy
body: <p>i have an error </p>
  
  <blockquote>
    <p>Access to XMLHttpRequest at '<a href="http://localhost:3000/framework/create" rel="nofollow noreferrer">http://localhost:3000/framework/create</a>' from origin '<a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.</p>
  </blockquote>
  
  <p>how i fix it?</p>
  
  <p>i'm use angular v7 and express.js for backend</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  
  @Injectable({providedIn : 'root'})
  export class CommonService {
  
    uri = 'http://localhost:3000/framework';
  
    constructor(private http: HttpClient) { }
  
    addFramework(framework, bahasa) {
      const obj = {
        framework: framework,
        bahasa: bahasa
      };
      console.log(obj);
      this.http.post(`${this.uri}/create`, obj)
          .subscribe(res =&gt; console.log('Done'));
    }
  
  
  }</code></pre>
  </div>
  </div>
  </p>