What is the right way in production for doing CORS thing in the latest version?
My function:
 public fetchData() {
    console.log("GET WITH HEADERS");
    return this.http.get('http://192.168.31.73:8080/myjersey/rest/hello/dd').map(
      (response) => response
    )
      .subscribe(
      (data) => console.log(data)
      )
  }
  public authentication(email, password) {
    console.log("POST WITH HEADERS");
    const body = { name: 'Brad' };
    this.http
      .post('http://192.168.31.73:8080/myjersey/rest/hello/dd', {
        email: email,
        password: password
      }, {
        headers: new HttpHeaders().set('Access-Control-Allow-Origin', '*')
          .set('Access-Control-Allow-Credentials', 'true')
          .set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE')
          .set('Access-Control-Allow-Headers', 'X-Custom-Header'),
      })
      .subscribe();
  }
below is the exception I am getting:
Failed to load http://192.168.31.73:8080/myjersey/rest/hello/dd: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
Somehow my Http Get is working but not POST.Please suggest what should i do in this case i have added Access-Control-Allow-Origin in both request and response still getting CORS issue.
PS: I have no knowledge of PHP. I am using Jersey Rest Services with angular.


 
    