ERR_SSL_PROTOCOL_ERROR 当我尝试连接本地主机时

ERR_SSL_PROTOCOL_ERROR when i try to connect with localhost

我开始研究节点 js,我正在尝试将离子应用程序与我创建的后端 nodejs 应用程序连接,但我收到此错误:

选项https://localhost:3000/insertnet::ERR_SSL_PROTOCOL_ERROR

import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { map } from 'rxjs/operators';

@Component({
  selector: 'app-cadastro-unidade',
  templateUrl: './cadastro-unidade.page.html',
  styleUrls: ['./cadastro-unidade.page.scss'],
})

export class CadastroUnidadePage implements OnInit {

  constructor(private http: Http) { }

  ngOnInit() {

  } 

  InsereDados(){
    let data = {
    };

    this.http.post('https://localhost:3000/insert', data).pipe(
            map(res => res.json())
        ).subscribe(response => {
            console.log('POST Response:', response);
        });
  }

}

app.get('/insert', function(req, res, next) {
var uri = "xxxx"
    MongoClient.connect(uri,{ useNewUrlParser: true }, function(err,client){const collection = client.db("test").collection("teste");
    console.log("connected");

    var ins={DataEntrada:"x",DataSaida:"x",HorarioEntrada:"x",HorarioSaida:"x",Prontuario:"x",TipoSaida:"x"};

    collection.insertOne(ins, function(err,res){
      console.log("data inserted");

    })

    client.close();
    })
    res.render(res)
});

端口 3000 通常用于纯 HTTP 而不是 HTTPS,这在您的设置中也可能是正确的。如果您在 URL 中使用 https:// 而不是 http://,它不会神奇地变成 HTTPS。

错误消息是由于您的客户端使用了错误的协议(HTTPS,即基于 TLS 的 HTTP)以及来自服务器的应答(普通 HTTP,没有 TLS)不是预期的有效 TLS 消息的结果客户 - 即 ERR_SSL_PROTOCOL_ERROR.

`