cordova wkwebview-engine-localhost插件返回403 forbidden

时间:2017-01-09 23:49:58

标签: javascript ios cordova cordova-plugins

我正在尝试在我的应用中使用cordova wkwebview-engine-localhost插件来为已导出的inVison原型提供服务。

到目前为止,我的项目文件结构如下所示:

.
├── build.sh
├── config.xml
├── hooks
│   └── README.md
├── node_modules
├── package.json
├── platforms
│   └── platforms.json
├── plugins
│   ├── fetch.json
│   └── ios.json
└── www
   ├── css
   │   └── index.css
   ├── external_app
   │   └── index.html
   ├── img
   │   └── logo.png
   ├── index.html
   └── js
    └── index.js

我的config.xml如下所示:

<?xml version='1.0' encoding='utf-8'?>
<widget id="my.project.id" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>wkwvtest</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="http://localhost:0" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<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:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>
<preference name="AlternateContentSrc" value="http://localhost:0" />

我安装了以下插件,如下所示:

cordova platform add ios
cordova plugin add cordova-plugin-device
cordova plugin add cordova-plugin-console
cordova plugin add cordova-plugin-inappbrowser
cordova plugin add https://github.com/apache/cordova-plugins.git#master:wkwebview-engine-localhost

然后当我尝试从index.js中编写的代码加载external_app索引页时如下:

  var url = "external_app/index.html";
  console.log("opening the url : ", url);      
  cordova.InAppBrowser.open(url, '_blank', 'localtion=no');

上面的代码返回403禁止错误。

enter image description here

我的package.json也如下所示:

{
  "name": "wkwvtest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
  "urijs": "^1.18.4"
},
"devDependencies": {},
"scripts": {
 "test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
 }

我正在使用ios cordova 4.3.1并在Xcode中使用ios 9.0进行构建。

当我以file://打开时,这可以正常工作,而不是通过服务器提供文件。

有人可以指出我错过了什么吗?也可以随时回复任何更多的说明和信息。

我也上传了我的项目here。您可以使用build.sh文件在mac上下载并运行该项目。您只需要安装node和cordova。

0 个答案:

没有答案