我有用于测试的开发人员服务器.它们具有SSL自签名证书,允许我们通过HTTPS测试Web应用程序,但有明显的警告证明证书不可验证.
这没关系,但是我有一个服务工作者会抛出一个错误 navigator.serviceWorker.register
SecurityError:无法注册ServiceWorker:获取脚本时发生SSL证书错误.
如何将Service Worker与具有自签名证书的Intranet测试服务器一起使用?
我在使用Chrome上的HTTP在我的计算机上本地运行的网站上使用地理位置.但是这不起作用,因为我在HTTP上运行而不是HTTPS.
在控制台上它说:
getCurrentPosition() and watchPosition() no longer work on insecure origins.
To use this feature, you should consider switching your application to a
secure origin, such as HTTPS. See https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins
for more details.
Run Code Online (Sandbox Code Playgroud)
为了在不安全的起源上弃用强大的功能,它说使用--unsafely-treat-insecure-origin-as-secure="http://example.com"旗帜开始镀铬.我运行的命令类似于:
chrome.exe --unsafely-treat-insecure-origin-as-secure="http://hello.app"
Run Code Online (Sandbox Code Playgroud)
但是,仍会出现相同的错误消息.
我该如何解决这个问题.
我很难将angulars服务工作者整合到我的应用程序中.我按照指南进行操作至今.我可以在主屏幕上创建一个快捷方式并启动到我的应用程序中.问题是我的应用程序不知何故不更新.如果我改变一个按钮的名称,构建应用程序,并把它放到我的服务器应用程序仍显示旧版本,直到我打了F5(重新启动应用程序并没有帮助).
我试着将以下代码放入我的应用程序的ngOnInot中,但它没有帮助
ngOnInit() {
if (this._SwUpdate.isEnabled) {
setInterval( () => {
this._SwUpdate.checkForUpdate().then(() => console.log('checking for updates'));
}, this.updateInterval);
this._SwUpdate.available.subscribe(() => {
console.log('update found');
this._SwUpdate.activateUpdate().then(() => {
console.log('updated');
window.location.reload();
});
});
}
Run Code Online (Sandbox Code Playgroud)
}
该应用程序正在我的apache2 linux机器上运行.我的apache缓存了什么,或者为什么我的应用程序没有意识到有新版本?
在此先感谢您的帮助 :)
编辑:
我的ngsw-config.json
{
"index": "/index.html",
"assetGroups": [{
"name": "roomPlan",
"installMode": "prefetch",
"resources": {
"files": [
"/index.html",
"/*.css",
"/*.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}]
}
Run Code Online (Sandbox Code Playgroud)
编辑2:
如果我使用"http-server"在本地运行应用程序,但是当我将文件复制到我的apache时,它不会检测到更新.在网络选项卡中,我可以看到间隔工作,应用程序每隔3秒从服务器获取一个新的"ngsw.json".如果我更新我的应用程序,我可以看到"ngsw.json"的响应中有新的哈希值.之后,浏览器从我的服务器加载新的"index.html"和"main.***.js",但应用程序不应用新版本.根据我的代码,它应该说"发现更新",但没有任何反应.