What value should I give the scope attribute in my manifest.json file when serving a Progressive Web App from a local IP address with a port number?

Frank picture Frank · Nov 4, 2017 · Viewed 9k times · Source

I am having a problem with web app manifest scope on my local Node JS test server. I cannot get the correct scope because the port number on the IP address gets in the way. I am accessing my server with the following address:

https://192.168.0.101:2468/

When I use Chrome dev tools to look at my manifest, under the Application tab it shows the url of the manifest file to be: :2468/manifest.json but :2468 is not a directory in my root folder.

I keep all my files in the root directory, including the server.js, the manifest.json, and the index, called my-app.html

_ website-directory
|_ server.js
|_ manifest.json
|_ my-app.html

In my manifest file I have:

{

  "scope": "./",
  "start_url": "my-app.html"

}

Everything works perfectly when I upload the code to my Github Pages site here: working example. I think the problem is coming from the :2468 behind my IP address. I do not have this problem with a fully qualified domain name like I have with Github Pages.

If I try to put the port number into the manifest's scope like so:

  "scope": "./:2468/",
  "start_url": "my-app.html"

It breaks the scope of my manifest and I get this warning: Manifest: property 'scope' ignored. Start url should be within scope of scope URL. Which makes perfect sense because :2468 is not a folder in my directory. It's just something Chrome decided to attach to the url of my manifest file.

How do I resolve the scope of my manifest file to ignore the port number? Why does Chrome dev tools indicate that my manifest is in the :2468 directory that does not exist?

The reason this is a problem is because my web app will not open in app mode, with a full screen window and splash screen. It only opens in a browser with a url bar and doesn't seem to be using the app manifest at all.

UPDATE: 11/05/17

By using the URL https://192.168.0.101:2468/my-app.html I can access my web app without dev tools showing :2468/ in my manifest url. My app does install to both the home screen and the app drawer, but it only opens in a browser rather than a full screen app with a splash screen. I get no warnings about the manifest scope, and my service worker registers and runs perfectly. I am beginning to think that progressive web apps cannot be installed from an IP address, but only fully qualified domain names. Could this be the problem?

Answer

Nathan Heffley picture Nathan Heffley · Nov 5, 2017

You're correct, Progressive Web Apps must be installed at a somewhat proper URL because they require that scope to operate properly. Without the scope being enforced, a rogue service worker could gain access to sites that it shouldn't.