Dynamically webview resources fail to load in some browser/OS combinations
- 主要言語
- TypeScript
- スター
- 79.3k
- フォーク
- 6.8k
- 平均マージ
- 2日 6時間
- マージ済み PR(30日)
- 41
説明
Hi, I have two issues, they may all be related to https certificates.
- One is `code-server` prompt can‘t register serviceworker error
- The other is that I can't `load resources dynamically` on my expansion webview.
I run `code-server --host 0.0.0.0 --port 8223 --cert` in docker `ubuntu:20.04`, and expose `8223` in my Windows 10 host, but I get an ssl error when I open a exntesion webview in code-server in my company.
when I use `Chrome command line` "**--ignore-certificate-errors**", my extension webview can't dynamic loading of resources(eg. js, css), which cause the page style confusion, the Chrome dev tool network display the resource keep pending until it fails.
At first, I thought it was the invalid certificate problem,but even if I use a valid certificate, I **still** can't dynamic loading resources.(**Without any certificate errors and any Chrome command line options**)
I use something like this to dynamic loading resources
```
function addCss(path, callback) {
if(!checkcache(path)) { /*Check if it has been loaded*/
var head = dom.getElementsByTagName('head')[0];
var link = dom.createElement('link');
link.href = path;
link.rel = 'stylesheet';
link.type = 'text/css';
head.appendChild(link); /*Add to HTML*/
link.onload = link.onreadystatechange = function() { /*whether the loading is successful*/
if(!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
link.onload = link.onreadystatechange = null;
callback();
}
};
cache[path] = 1; /*Store loaded paths*/
}
};
```
-->
## OS/Web Information
- Web Browser: Chrome 90.0.4430.212 64bit
- Local OS: Windows 10
- Remote OS: ubuntu:20.04 (docker)
- Remote Architecture: x86
- `code-server --version`: 3.9.0
## Steps to Reproduce
1. installl code-server 3.9.0 in docker ubuntu:20.04
2. code-server --host 0.0.0.0 --port 8223 --cert
3. enter localhost:8888 and open my extension webview
## Expected
No error.
## Actual
get an error in bottom right corner:
```
Error loading webview: Could not register service workers: SecurityError: Failed to register a ServiceWorker for scope ('https://localhost:8223/webview/') with script ('https://localhost:8223/webview/service-worker.js'): An SSL certificate error occurred when fetching the script.
```
## Screenshot

コントリビューションガイド
評価
この issue はまだ評価されていません。