3
votes

Does anyone have any idea on how to run a sencha touch 2 app without installing a web server (like LAMP/XAMP). (PS : I'm new to Sencha Touch)

I know there is one way - Including phonegap's javascript file in the app.json of the Sencha Touch 2 app. Which'll look like this

"js":
    {
        "path": "cordova-2.5.0.js"  
    }

After this the sample application runs on the browser without the web server.

  1. Is there ANY other way?

  2. How does adding the phonegap js file help in running the sencha touch app without web server anyway??

1

1 Answers

3
votes

Starting chrome with --allow-file-access-from-files --disable-web-security flags also does the trick.

Sencha requires web server because if app is in development mode microloader in sencha make Ajax request for app.json file and from it, it loads other files. You can see this in

../sencha-sdk/mircroloader/development.js

file with following code -

var xhr = new XMLHttpRequest();
xhr.open('GET', 'app.json', false);

When you start chrome with above mentioned flags, chrome does allow making ajax requests even if file opened with file://.... url scheme.

When you deploy the app after compressing js/css with sencha cmd, all files are bunched into one single file. You no more need a webserver in that case.


Update

From Cordova docs for Whitelisting domain

Domain whitelisting in Apache Cordova is a security model that controls access to outside domains, such as http://google.com. The default security policy is to block all network access. The application developer can then declare access to specific network domains and subdomains.

And

In the Widget Access specification, the element is used to declare access to specific network domains. In the future, Apache Cordova will abstract the platform whitelisting implementations to the W3C Widget Access specification. However, for now each platform must implement it's own domain whitelisting.

Moreover, W3C Widget Access does not enclose the security and user agent enforce policy. It is defined in XMLHTTPRequest.

So what Cordova essential does is, adds an exception in policy to allow access to certain network resource outside app domain with whitelisted domains.