Angular Proxy适用于GET请求但POST请求失败

时间:2017-11-09 14:52:36

标签: angularjs node.js mongodb angular proxy

我在我的角度应用程序上为我的请求设置了代理,并且我得到了我的GET请求以正确地重定向到

  

http://localhost:3000/api/users

但我的POST请求仍然转到

  

http://localhost:4200/api/users

这是我的代理代码

<asp:Label ID="Label1" runat="server" Text="Department" AssociatedControlID="DropDownList4"></asp:Label>

为什么当他们向同一条路线发出请求时会失败?

1 个答案:

答案 0 :(得分:0)

问题出在POST而不是GET上,因为POST具有主体。 正文将重定向到目标。

如果您无法通过主体,则需要将主体设置为

JSON.stringify(body)