Javascript POST请求对Postman有效,但对Angular 11无效
我有一个HTTP post请求,用于ping Django后端。当邮递员发出请求时,我能够得到有效的响应。然而,使用语义相同的json负载从Chrome启动时,我收到了400个错误请求 下面是我在angular中使用的构建主体的json模型 标题保持不变,授权也完全相同(使用基本身份验证)。我唯一可能想到的问题是CORS,不过,我正在代理它来解决这个问题Javascript POST请求对Postman有效,但对Angular 11无效,javascript,angular,typescript,http-post,angular-httpclient,Javascript,Angular,Typescript,Http Post,Angular Httpclient,我有一个HTTP post请求,用于ping Django后端。当邮递员发出请求时,我能够得到有效的响应。然而,使用语义相同的json负载从Chrome启动时,我收到了400个错误请求 下面是我在angular中使用的构建主体的json模型 标题保持不变,授权也完全相同(使用基本身份验证)。我唯一可能想到的问题是CORS,不过,我正在代理它来解决这个问题 export class RealResult { node: string; source: string; destina
export class RealResult {
node: string;
source: string;
destination: string;
protocol: string;
source_port: string;
destination_port: string;
direction: string;
acl_ID: string;
zone: string;
action: string;
timestamp: string;
flowID: string;
constructor(data: RealResult) {
this.node = data.node;
this.source = data.source;
this.destination = data.destination;
this.protocol = data.protocol;
this.source_port = data.source_port;
this.destination_port = data.destination_port;
this.direction = data.direction;
this.acl_ID = data.acl_ID;
this.zone = data.zone;
this.action = data.action;
this.timestamp = data.timestamp;
this.flowID = data.flowID
}
}
export class Success {
results: Result[];
constructor() {
this.results = []
}
}
你能看看Chrome的网络标签,看看Angular请求的真实内容吗?绝对:运行了json diff:然后,说到CORS,你在代理Angular调用,所以我猜你调用端口4200。端口4200是否也与邮递员一起工作,以确保问题不是从代理提交的?我确实调用了端口4200。但我不确定如何在postman中配置端口4200。注意:证书链中有一个自签名证书。不确定这是否会有帮助。嗯,证书绑定到主机和端口,因此可能会干扰。。。