简体   繁体   English

Sencha Cordova Android ERR_FILE_NOT_FOUND(与sencha Web目录一起部署在tomcat实例上的API)

[英]Sencha Cordova Android ERR_FILE_NOT_FOUND (API deployed on tomcat instance along with sencha web dir)

Okay so I've got a Sencha modern project (Sencha Touch) in ExtJS 6. I can run it in development or production and it works fine. 好的,我在ExtJS 6中有一个Sencha现代项目(Sencha Touch)。我可以在开发或生产中运行它,并且效果很好。 On my Tomcat instance I have the web dir deployed for all the js and css and a separate API project deployed which it interfaces with by making AJAX requests and getting the data back. 在我的Tomcat实例上,我为所有js和css部署了Web目录,并部署了单独的API项目,该项目通过发出AJAX请求并返回数据来与之交互。

I used cordova to build the Android debug-apk. 我使用cordova来构建Android debug-apk。 I use chrome://inspect/#devices to run it through the browser for logging purposes and when I go to log in on the apk it returns a (failed) net::ERR_FILE_NOT_FOUND not found. 我使用chrome:// inspect /#devices通过浏览器运行它以进行记录,当我登录apk时,它返回一个(失败的)net :: ERR_FILE_NOT_FOUND,但未找到。 Basically... when I click login on the local sencha project it goes to http://localhost:1841/api/login which works fine, but the cordova project returns the error file not found and the login request goes to file:///api/login . 基本上...当我单击本地sencha项目上的登录名时,它会转到http:// localhost:1841 / api / login ,它可以正常工作,但是cordova项目返回未找到的错误文件,并且登录请求转到file:/ // api / login Why is it using file:///?? 为什么使用file:///? I know because it's an apk and it's on the local filesystem, but I've added the additional rules into the config.xml (below) 我知道,因为它是一个apk,并且在本地文件系统上,但是我已将其他规则添加到config.xml中 (如下)

<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />

When I crack open the apk there is no api project so it clearly can't find it. 当我打开apk时,没有api项目,因此显然找不到它。 It's deployed on to my local Tomcat instance so I guess that's why it all works fine locally. 它已部署到我的本地Tomcat实例上,所以我想这就是为什么它们在本地都能正常工作的原因。 Does anybody know how to fix this? 有人知道如何解决此问题吗? Ie should the api project be in the apk or should it still make the http requests to the api like I mentioned above (this makes the most sense to me but for some reason it uses file:///...). 即应该将api项目放在apk中还是应该像上面提到的那样仍然向api发出http请求(这对我来说最有意义,但出于某种原因,它使用file:/// ...)。

Do I need to specify anywhere in the app.js/config.xml etc what url to use when it makes the login requests? 我是否需要在app.js / config.xml等中的任何地方指定在发出登录请求时要使用的URL? (ie use http:/ / instead of file:// etc). (即使用http :///而不是file://等)。

I also added this to the index.html which the cordova documentation mentioned: 我还将此添加到cordova文档提到的index.html中:

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src *  'unsafe-inline'; script-src *  'unsafe-inline'; media-src *">

A massive massive thanks to anybody who can help me - I really appreciate it!! 非常感谢任何可以帮助我的人-我真的很感激!

Jamie 杰米

Three questions in as many years and no replies to any of them. 多年以来一直存在三个问题,但没有人回答。 I fixed this now. 我现在已经解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM