Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the start_url of a manifest.json to be the root of the site?

I have a manifest.json and it has a start_url property that I want to point to the first file of my single page application.

This is index.html, and it's the root of the site. I want this to be the start_url, but that file is never asked for as a URL.

How do I point start_url at the relative root of the site?

For instance, suppose the site is at https://example.com, what should the value of start_url be in https://example.com/manifest.json? I want the PWA to start at https://example.com and not https://example.com/index.html. The PWA might be put on a different domain, so start_url needs to be relative, not absolute.

like image 812
Keith Avatar asked Jul 31 '17 09:07

Keith


People also ask

What should be the start URL in start_url in manifest JSON?

The start_url member is a string that represents the start URL of the web application — the preferred URL that should be loaded when the user launches the web application (e.g., when the user taps on the web application's icon from a device's application menu or homescreen).

Where should manifest JSON be located?

First check if manifest. json is applied in the browser. For that open developer window by pressing shortcut F12. In Application tab, click Manifest option and see if it displays information that you have set.


2 Answers

If you are running in the root of a site, for instance https://example.com/manifest.json or https://test.example.com/manifest.json you can use "start_url": "/".

However, this will also map https://example.com/test/manifest.json to https://example.com/, which fails because it's in a folder outside the scope of the manifest.

Instead, if you are using a sub-directory you need to set both a scope and the start_url:

"start_url": "./" "scope": "." 

This will cause https://example.com/test/manifest.json to map to https://example.com/test/ as expected.

like image 97
Keith Avatar answered Sep 21 '22 16:09

Keith


Your start_url should be set to the following in your manifest file.

"start_url": "/" 

Source: https://developers.google.com/web/fundamentals/integration/webapks

like image 41
Eric V. Avatar answered Sep 20 '22 16:09

Eric V.