Angular 飞行前的响应没有HTTP ok状态。403英寸角6

Angular 飞行前的响应没有HTTP ok状态。403英寸角6,angular,rest,cors,angular6,preflight,Angular,Rest,Cors,Angular6,Preflight,我试图发出PUT请求,但出现以下错误: Failed to load <localhost:8080/uaa/groups/dfsfaes8323df32>: Response for preflight does not have HTTP ok status. 显然,当我发出GET和POST请求时,它可以工作,在postman中也可以工作,但在我的代码中,它不适用于PUT请求 这是我的要求: let link = "https://ice.<mydomain>.co

我试图发出PUT请求,但出现以下错误:

Failed to load <localhost:8080/uaa/groups/dfsfaes8323df32>: Response for preflight does not have HTTP ok status.
显然,当我发出GET和POST请求时,它可以工作,在postman中也可以工作,但在我的代码中,它不适用于PUT请求

这是我的要求:

let link = "https://ice.<mydomain>.com/uaadev/Groups/{groupId}";
link = link.replace("{groupId}", data);
const updLoad = {
  displayName: this.groupInfoObjects.displayName,
  description: this.groupInfoObjects.description,
  zoneId : "uaa",
  schemas: [
 "urn:scim:schemas:core:1.0"
  ]
};
let Header = new Headers({
  Authorization: `Bearer {token}`.replace("{token}", this.token),
  "Content-Type": "application/json",
  Accept: "application/json",
  "if-Match":"*"
});
let Option = new RequestOptions({ headers: Header });

this.http.put(link, updLoad, Option).subscribe(
  res => {
    console.log(res);
    console.log(res.status);
    if (res.status === 200) {
 this.fetchGroupInfo(this.dataservice.getDTO("GroupId"));
      swal(" Updated Successfully");
    }
  },
  error => {
    console.log("errroroorororororor");
    console.log("error object " +error);
  }
);

这是因为您必须确保服务器配置为在PUT请求之前为浏览器触发的请求发送200或204

请参见第一个响应

使用PUT获得此选项的原因是,它会触发浏览器的附加飞行前请求,以查看有关触发此选项的方法的更多信息。基本上,浏览器是在PUT之前ping服务器

令人沮丧的是,这似乎是一个前端问题,因为PUT请求将在测试时工作,即如果您使用postman而不是浏览器


因此,这不是前端问题,无法使用Angular解决。

这是因为您必须确保服务器配置为在PUT请求之前为浏览器触发的请求发送200或204

the process for solving these process is listed below:

1.create a proxy.conf.json file 
2.set it up like this:copy and paste the below code
{
  "/dev/*": {
    "target": "https://google.com/",
    "secure": false
  },
  "changeOrigin": false,
  "logLevel": "debug"
}

3. add this to your package.json :
"start": "ng serve --proxy-config ../Activated/proxy.conf.json",
Note:Activated is the folder name that contains the angular code.
4.you place your url link:
let link = "dev/Groups/{groupId}" (just a sample)`enter code here`

5.npm start to restart you application.
请参见第一个响应

使用PUT获得此选项的原因是,它会触发浏览器的附加飞行前请求,以查看有关触发此选项的方法的更多信息。基本上,浏览器是在PUT之前ping服务器

令人沮丧的是,这似乎是一个前端问题,因为PUT请求将在测试时工作,即如果您使用postman而不是浏览器


因此,这不是前端问题,无法使用Angular解决。

您需要配置https://ice..com 服务器,以便允许对/uaadev/Groups/{groupId}端点的PUT请求。现在,403服务器响应表示服务器不允许对/uaadev/Groups/{groupId}`端点的PUT请求。在前端JavaScript中,您无法做任何事情来影响/改变这一点。在这里标记@sideshowbarker-是的,它与角度或前端代码完全无关。您必须在后端配置CORS,以便在Acces Control Allow METHOLS标头中包含PUT或PATCH。您可能可以使用不透明获取,但这取决于您的后端设置。不透明获取是通过设置{mode:'no-cors'}来完成的,对吗?您需要配置https://ice..com 服务器,以便允许对/uaadev/Groups/{groupId}端点的PUT请求。现在,403服务器响应表示服务器不允许对/uaadev/Groups/{groupId}`端点的PUT请求。在前端JavaScript中,您无法做任何事情来影响/改变这一点。在这里标记@sideshowbarker-是的,它与角度或前端代码完全无关。您必须在后端配置CORS,以便在Acces Control Allow METHOLS标头中包含PUT或PATCH。您可能可以通过不透明获取,但这取决于您的后端设置。不透明获取是通过设置{mode:'no-cors'}完成的,对吗?
the process for solving these process is listed below:

1.create a proxy.conf.json file 
2.set it up like this:copy and paste the below code
{
  "/dev/*": {
    "target": "https://google.com/",
    "secure": false
  },
  "changeOrigin": false,
  "logLevel": "debug"
}

3. add this to your package.json :
"start": "ng serve --proxy-config ../Activated/proxy.conf.json",
Note:Activated is the folder name that contains the angular code.
4.you place your url link:
let link = "dev/Groups/{groupId}" (just a sample)`enter code here`

5.npm start to restart you application.