Git Product home page Git Product logo

cordova-local-webserver's Introduction

Cordova Local WebServer

This Apache Cordova plugin will install a local web server in your iOS app, and will serve the contents of your www directory, looking for an index page of index.html.

After the plugin is installed, it changes the config.xml in your project root by modifying this tag to:

    <content src="http://localhost:0" />

For the local web server to start, the url must be http://localhost, and you can set the port to whatever you want in the url, the local web server will use this as the port automatically. If you set the port to "0", it will select a randomized and free port.

Check your console log for errors in configuration.

localStorage, IndexedDB persistence

If you plan on using HTML5 localStorage and/or IndexedDB, you must choose a fixed port in the content tag specified above. This is because of the HTML5 Origin policy (scheme, domain and port must be the same).

In the config.xml in your project root, change the '0' port to a number between 1 and 49152 (avoiding the ephemeral port range of 49152 to 65535 on iOS). For example:

    <content src="http://localhost:49000" />

This port number must be consistent across all app launches for saved data to be accessed.

Security Caveats

In order to limit access to your app, requests are restricted to localhost and are protected with an auth token.
This should effectively restrict access to the server to your app.

This plugin is only compatible with the 3.7.0 release of cordova-ios, or greater.

Credits

The local web server implementation is from https://github.com/swisspol/GCDWebServer

To update with the latest from that repo:

    git remote add GCDWebServer https://github.com/swisspol/GCDWebServer.git
    git subtree pull --prefix=src/ios/GCDWebServer --squash GCDWebServer master

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.