Angular-JSON放置和删除返回403(但邮递员应用程序运行良好) [英] Angular - JSON Put and Delete Returns 403 (But postman app works well)

查看:62
本文介绍了Angular-JSON放置和删除返回403(但邮递员应用程序运行良好)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个rest api,可以使用post和get请求.但是,当我要使用放置和删除请求时,它会返回错误403.而且,当我尝试使用Postman应用程序(用于JSON请求的应用程序)放置和删除时,一切都很好.我真的很困惑.让我用一些屏幕截图来证明问题. (出于安全原因,我已审查了这些链接,对此表示抱歉)

I have an rest api which i could use post and get requests. But when i want to use put and delete request it returns error 403. But also when i try to put and delete with Postman app (an app for json requests) all is works well. Im really confused. Let me prove the problem with some screenshots. (Im censored links for security, sorry for that)

Chrome控制台; 邮递员应用程序;

Chrome console; Postman App;

任何我的输入代码;

  /** PUT: update the firm on the server */
updateFirm (firm: Firm): Observable<any> {
 console.log(firm);

 return this.http.put(this.firmUrl+"put/"+String(firm.id), firm, httpOptions).pipe(
   tap(_ => console.log(`updated firm id=${firm.id}`)),
   catchError(this.handleError<any>('updateFirm'))
 );
}


如果您能帮助我,我将不胜感激.祝你有美好的一天


I will be very appreciated if you could help me. Have nice day

推荐答案

它看起来像是CORS错误,您正在从本地主机上的本地计算机到其他URL上的后端执行http请求.解决此问题的唯一方法是允许后端发出来自不同来源的请求.或者可能在您的本地计算机上运行后端.

It looks like a CORS error, you are doing the http request from your local machine on localhost to the backend on a different URL. The only way to solve this would be to allow requests from different origins on the backend. Or possibly to run the backend on your local machine.

这篇关于Angular-JSON放置和删除返回403(但邮递员应用程序运行良好)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆