Ionic/Angular $http.get 返回预检响应具有无效的 HTTP 状态代码 404

Ionic/Angular $http.get returning Response for preflight has invalid HTTP status code 404

我正在 IONIC 开发应用程序。我在 Angular JS 中发出 $http.get 请求,当我成功登录并尝试使用身份验证 header 中发送的令牌加载用户配置文件时,它给我 404 错误.

它在 chrome 中产生错误,尽管我启用了 CORS。请检查 screenshot:

现在,如果我在 POSTMAN 中尝试 url,一切正常。请参阅下面的 screenshot

我被这个错误困住了,有人可以帮助我吗?

Ionic 说的

There are two ways to solve the issue: The first, and easier, solution is to just allow all origins from your API endpoint. However, we can’t always control the endpoint we are accessing. What we need, then, is a request that does not specify an origin.

We can do this by using a proxy server. Let’s look how the Ionic CLI provides

Reference

什么有效但不完全好用

一个简单的解决方案就是在您的浏览器中添加一个 CORS 插件,一切都会正常进行。

Plugin Link

代理服务器

如果你想要一个代理服务器有这个教程:

Link