Support serving /manifest.json, /sw.js, & /offline.pwa.html (#6461)

This commit is contained in:
Martin Rüegg 2023-07-25 18:13:12 +02:00 committed by GitHub
parent 9dba5ef34d
commit 640a6693d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ HumHub Changelog
1.15.0 (Unreleased)
-------------------
- Fix #6461: Test server support to serve web module's `/manifest.json`, `/sw.js`, & `/offline.pwa.html`
- Enh #6460: Test server output: print application requests
- Fix #6423: log.fata in frontend logging is redirected to log.fatal, which did not work
- Fix #6220: User Soft Delete doesn't remove third party auth references

View File

@ -13,7 +13,7 @@ if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
}
if (isset($_SERVER['REQUEST_URI']) && preg_match('/\.(?:css|json|js|png|jpg|jpeg|gif|ttf|woff|woff2)(\?.+)?$/i', $_SERVER['REQUEST_URI'])) {
if (isset($_SERVER['REQUEST_URI']) && preg_match('/^[^?]*\.(?:css|(?<!manifest\.)json|(?<!sw\.)js|png|jpg|jpeg|gif|ttf|woff|woff2)(\?.+)?$/i', $_SERVER['REQUEST_URI'])) {
return false; // serve the requested resource as-is.
}

View File

@ -47,6 +47,10 @@ class Request extends \yii\web\Request
if ($this->cookieValidationKey == '') {
$this->cookieValidationKey = 'installer';
}
if (defined('YII_ENV_TEST') && YII_ENV_TEST && $_SERVER['SCRIPT_FILENAME'] === 'index-test.php' && in_array($_SERVER['SCRIPT_NAME'], ['/sw.js', '/offline.pwa.html', '/manifest.json'], true)) {
$this->setScriptUrl('/index.php');
}
}
/**