android - webview - access-control-allow-origin 不允许来源(使用cordova将角度转换为移动)
问题描述
我正在尝试使用 Alfresco adf 组件(https://github.com/Alfresco/alfresco-ng2-components)创建一个角度应用程序,并且也需要一个移动应用程序,所以我决定使用 cordova 生成 apk。
我按照以下教程(https://medium.com/@nacojohn/convert-your-angular-project-to-mobile-app-using-cordova-f0384a7711a6)生成我的apk。
一切似乎都很好,apk 已生成并安装在 BlueStack 中,直到我必须在我的应用程序中登录。
access-control-allow-origin 不允许来源
我知道我需要有一个白名单策略来导航应用程序 webview
配置文件
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloWorld</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-device" spec="^2.0.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<engine name="android" spec="^7.0.0" />
<engine name="ios" spec="^4.5.4" />
</widget>
索引.html
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"
我的 Angular Web 应用程序有一个开发服务器代理来解决 CORS 问题
proxy.conf.json
{
"/alfresco": {
"target": "server-url",
"secure": false,
"changeOrigin": true
},
"/activiti-app": {
"target": "another-server-url",
"secure": false,
"changeOrigin": true
}
}
我不知道我还需要做什么。我做错了什么吗?需要做更多的事情吗?
谢谢
解决方案
推荐阅读
- android - 通知管理器不显示通知
- android - 没有 UI 的 Android 应用程序:如何在每次运行应用程序时停止瞬时闪烁
- react-native - 反应原生如何保存从图像选择器包中挑选的图像
- excel - 一个条件格式宏覆盖另一个
- docker - 从 mac os 部署到 linux/docker 生产主机的映像位置是什么?
- node.js - Content-Security-Policy 不会在 React 中从外部源加载图像
- azure - 如何在 Visual Studio 2019 窗口中创建的 Mac 上的 Visual Studio Code 中本地运行多个 C# Az 函数应用程序?
- java - spring-boot EntityListener,应用上下文中一些bean的依赖形成一个循环
- java - Spring Boot 在控制器 api 上出现 404 错误
- mysql - MariaDB:group by 不计算条目