且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

离子+角 - 如何避免" 404未找​​到(从高速缓存)QUOT;后POST请求?

更新时间:2022-01-26 08:41:43

A lot人是experiencing这。

我只是碰到了同样的问题。这似乎它与科尔多瓦的新版本新的安全策略做。

I just ran into the same problem. It seems it has to do with a new security policy in new versions of Cordova.

下面是我如何解决它:

我安装科尔多瓦的白名单插件

cordova plugin add cordova-plugin-whitelist

然后,添加内容政策在 index.html的作为元标签(使用您自己的主机或*接受所有请求):

Then, add your content policy in your index.html as a meta tag (using your own host or '*' for accepting all requests) :

<meta http-equiv="Content-Security-Policy" content="default-src 'self' yourhost.com ws://localhost:35729 data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' localhost:35729 'unsafe-eval' 'unsafe-inline';">

默认的s​​rc 用于一般要求;在 WS://本地主机:35729 主机被用于实时重载的离子服务

default-src is used for general requests; the ws://localhost:35729 host is used for live-reload in ionic serve.

脚本的src 用于安全执行脚本

不安全的内联不安全-EVAL 要求,以便角正常工作。

unsafe-inline and unsafe-eval are required in order for angular to work properly.

数据:差距:https://ssl.gstatic.com 只用在iOS

表示的当前主机的index.html 文件。

您必须添加自己为了您的要求工作。不要忘了,如果他们是非标准添加协议和端口号

You'll have to add your own in order for your requests to work. Don't forget to add the protocol and the port if they're non-standard

您可以跳过meta标签,如果你不想要它,但你会从白名单中的插件得到很多的警告。

You can skip the meta tag if you don't want it, but you'll get a lot of warnings from the whitelist plugin.

如何在插件的自述

然后重建您的应用程序,它应该工作了。

Then rebuild your app, and it should work again.