How to solve the error of https protocol post method?


#1

In below code I try to post form to registration but it fails:

submitForm() {
    let headers = new Headers(
      {
        'Content-Type': 'application/json'
      });
    let options = new RequestOptions({ headers: headers });

    let data = JSON.stringify({
      name: this.form.name,
      phone: this.form.phone,
      time: this.form.time,
      date: this.form.date
    });
    //console.log(data);

    let url = 'https://mobileapp.mydomain.com/api/registrations';

    return new Promise((resolve, reject) => {
      this.http.post(url, data, options)
        .toPromise()
        .then((response) => {
          console.log('API Response : ', response.status);
          resolve(response.json());
        })
        .catch((error) => {
          console.error('API Error : ', error.status);
          console.error('API Error : ', JSON.stringify(error));
          reject(error.json());
        });
    });
  }


#2

I can’t read your screenshots, but let’s clean this up.

You don’t need to set the content type. You don’t need to make headers. You don’t need to make RequestOptions. You don’t need to stringify payloads manually. You don’t need to explicitly instantiate a Promise.


#3

this issue seems was related with loopback and nginx SSL certificate. it seems chrome dosen’t allow to Self signed certificates since 58+ version.

this error was resolved when SSL problem was solved.

But the question is, still http post is not secure enough I can read post by fiddler 4.


#4

LetsEncrypt offers free SSL certs; there’s no need to have self-signed any more.