mirror of
https://github.com/humhub/humhub.git
synced 2025-02-12 03:26:25 +01:00
Fix: Omit credentials in offline page request
This commit is contained in:
parent
2917569c0c
commit
7a03ef0343
@ -8,7 +8,6 @@
|
||||
|
||||
namespace humhub\modules\web\pwa\controllers;
|
||||
|
||||
use humhub\components\access\ControllerAccess;
|
||||
use humhub\components\Controller;
|
||||
use humhub\modules\ui\Module;
|
||||
use Yii;
|
||||
@ -24,12 +23,7 @@ use yii\helpers\Url;
|
||||
*/
|
||||
class ServiceWorkerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Allow guest access independently from guest mode setting.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $access = ControllerAccess::class;
|
||||
|
||||
public $baseJs;
|
||||
public $additionalJs;
|
||||
|
||||
@ -49,14 +43,16 @@ class ServiceWorkerController extends Controller
|
||||
|
||||
$offlinePageUrl = Url::to(['/web/pwa-offline/index']);
|
||||
$this->baseJs .= <<<JS
|
||||
var CACHE = 'humhub-sw-cache';
|
||||
var OFFLINE_PAGE_URL = '{$offlinePageUrl}';
|
||||
|
||||
self.addEventListener('install', function (event) {
|
||||
console.log('********** The service worker is being installed.');
|
||||
|
||||
// Store "Offline" page
|
||||
var offlineRequest = new Request(OFFLINE_PAGE_URL);
|
||||
var offlineRequest = new Request(OFFLINE_PAGE_URL, {init: {
|
||||
credentials: 'omit'
|
||||
}});
|
||||
|
||||
event.waitUntil(
|
||||
fetch(offlineRequest).then(function (response) {
|
||||
return caches.open('offline').then(function (cache) {
|
||||
@ -75,7 +71,6 @@ JS;
|
||||
$this->baseJs .= <<<JS
|
||||
self.addEventListener('fetch', function (event) {
|
||||
var request = event.request;
|
||||
|
||||
// Check is "page" request
|
||||
if (request.method === 'GET' && request.destination === 'document') {
|
||||
event.respondWith(
|
||||
|
Loading…
x
Reference in New Issue
Block a user