gpt4 book ai didi

angular - HttpClient 无法忽略或绕过自签名证书错误

转载 作者:行者123 更新时间:2023-12-04 21:30:06 25 4
gpt4 key购买 nike

我曾尝试向服务器发送 POST 数据,但收到错误“net::ERR_CERT_INVALID”。如下所示的代码是我试图绕过错误但它仍然失败的代码。请帮忙指教。谢谢你。

import { HttpClient, HttpParams } from '@angular/common/http';

createData(data): Promise<any> {
let post_message = data;
let header_node = {
Accept: 'application/json',
rejectUnauthorized: 'false',
}
// this.oauth_header.Authorization = 'Bearer ' + access_token;
const url_params = new HttpParams()
.set('rejectUnauthorized', 'false')
.set('requestCert', 'false')
.set('insecure', 'true')

return this.http.post('https://ip/createdata', post_message, {
headers: header_node,

}).toPromise();

最佳答案

尝试将标题作为 HttpHeaders 传递至 POST方法。

import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';

createData(data): Promise<any> {

let post_message = data;
let header_node = {
headers: new HttpHeaders(
{ 'Accept': 'application/json' },
{ 'rejectUnauthorized': 'false' })
};

return this.http.post('https://ip/createdata', post_message, header_node).toPromise();
}

关于angular - HttpClient 无法忽略或绕过自签名证书错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54840830/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com