Deployed but error "Not allowed to load local resource"

I deployed my Enyo 2.3 app to webOS. It works well in Safari/Chrome. On the device (TouchPad), however, I receive the following error:
[20131104-21:54:30.988979] error: Not allowed to load local resource: file://.media.cryptofs.apps.usr.palm.applications.com.blackcatworks.touchtax/media/cryptofs/apps/usr/palm/applications/com.blackcatworks.touchtax/assets/firstrun-notes.json
This comes from a command (shown below) within App.js that reads from a json to create and populate a database table (using the database-enyo.js package from OneCrayon). I think it is not otherwise relevant where the error comes from, and it is not otherwise related to the database. The error means I have done something else fundamentally incorrectly. I don't think I've placed my file in the incorrect place.
this.$.dbMAIN.setSchemaFromURL('./assets/firstrun-main.json');
Same result with:
this.$.dbMAIN.setSchemaFromURL('assets/firstrun-main.json');
By the way, I followed the instructions at http://blog.openwebosproject.org/post/39278618299/javascript-apps-for-open-webos-with-enyo-and-cordova.

Any tips?

Comments

  • edited November 2013
    I checked on Ian's code here, and it's detecting Enyo 2 and using the enyo.xhr.request call to load the file. That just passes the raw URL string you specify into Enyo.

    Here, it passes into the simplifyFileURL code. This creates an anchor link, tries to set that to the URL you request, and them pulls off the parts that aren't valid for files. It looks like this code isn't behaving on webOS 3.

    I just connected a debugger over to my TouchPad to see what window.location.host is for an app, and got a string like ".media.cryptofs.apps.usr.palm.applications.com.palm.app.calendar". It looks like the old LunaSystemManager would use fake host names to separate the context for each installed app.

    I'll file a fix for the XHR code tonight to ignore the host name when building file URLs. I don't know why I included it... I guess I thought it would always be blank.

    (bug filed as https://enyojs.atlassian.net/browse/ENYO-3520)
  • Thanks Ben! For now my workaround is to pull the .json file not from the local directory (the local file location), but from the Internet (a "http" location). But that wouldn't work if the device isn't connected to the Internet, but it's probably just as workable.
  • This fix was added to 2.3.0-pre.12, tagged yesterday. However, I'm having to update the fix to make it specific to webOS 3 -- we found a problem where if you host your app use a network drive, your base URL is something like file://127.0.0.42/mypath/to/my/index.html and then local file references don't resolve.
Sign In or Register to comment.