Super-Progressive-Web-Apps icon indicating copy to clipboard operation
Super-Progressive-Web-Apps copied to clipboard

Odd Behaviour When used Cross-Domain

Open vincentkoc opened this issue 7 years ago • 6 comments

Currently using wp-config.php to dynamically set the site domain name:

define('WP_SITEURL', $_SERVER['HTTP_HOST']);
define('WP_HOME', $_SERVER['HTTP_HOST']);

Now this is leading to some odd behaviour, the primary domain ayanajewellery.com vs. the sub-domain loaded us.ayanajewellery.com

Errors in Chrome console include: Uncaught (in promise) TypeError: Failed to fetch Uncaught (in promise) TypeError: Failed to update a ServiceWorker: Not found

vincentkoc avatar May 28 '18 13:05 vincentkoc

Hello @koconder

The manifest and service worker are static files right now where the domain names are written into. You will find these in the root folder of the WordPress install.

The solution in these cases might happen if we can get #38 happen. Currently we are exploring the possibility.

arunbasillal avatar May 28 '18 17:05 arunbasillal

@arunbasillal how is superpwa injected onto the page or loaded initially? As if browser is looking for a file i could easily do some magically rewrite rules on ngnix.

vincentkoc avatar May 29 '18 02:05 vincentkoc

Here is the service worker registration script

https://github.com/SuperPWA/Super-Progressive-Web-Apps/blob/10cd1b7dcf675a8f63a169a6bcb5d29a8c82a31a/public/sw.php#L201-L216

The error is not because of an incorrect URL to the service worker. But because in the service worker: https://www.ayanajewellery.com/superpwa-sw.js the links are hard coded to https://www.ayanajewellery.com.

arunbasillal avatar May 29 '18 04:05 arunbasillal

Thanks @arunbasillal - Could we leave the issue open till we have some update on #38 - Thanks

vincentkoc avatar Jun 07 '18 00:06 vincentkoc

You got it :+1:

arunbasillal avatar Jun 07 '18 03:06 arunbasillal

Hi @arunbasillal or others, could you please help me with the multi-domain setup as described above. Now that we have hooks like superpwa_sw_filename

Hows best to configure my site functions per domain?

vincentkoc avatar Mar 11 '19 00:03 vincentkoc