简体   繁体   中英

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. 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.

I used cordova to build the 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. 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 . Why is it using 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)

<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. It's deployed on to my local Tomcat instance so I guess that's why it all works fine locally. 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:///...).

Do I need to specify anywhere in the app.js/config.xml etc what url to use when it makes the login requests? (ie use http:/ / instead of file:// etc).

I also added this to the index.html which the cordova documentation mentioned:

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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