question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamically webview resources fail to load in some browser/OS combinations

See original GitHub issue

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

image

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:63 (43 by maintainers)

github_iconTop GitHub Comments

5reactions
mmitkevichcommented, Jul 8, 2021

I had similar problem with latest release 3.10, had to downgrade to 3.8. OSX/Chrome 91.0.4472.114

4reactions
code-ashercommented, Oct 6, 2021

Thank you for the info! I was able to replicate on Firefox and code-server 3.12.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamically webview resources fail to load in some ... - GitHub
when I use Chrome command line "--ignore-certificate-errors", my extension webview can't dynamic loading of resources(eg. js, css), which cause ...
Read more >
Android WebView not loading URL - Stack Overflow
In shouldOverrideUrlLoading() method, do not call WebView#loadUrl(String) with the request's URL and then return true. This unnecessarily ...
Read more >
WebView control for Windows Forms and WPF - Microsoft Learn
The WebView control shows web content in your Windows Forms or WPF desktop application. This is one of several wrapped Universal Windows ...
Read more >
Cross-Origin Resource Sharing (CORS) - MDN Web Docs
Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, ...
Read more >
Mobile Application Security & Privacy - Ostorlab's
WebView is an important component for mobile applications, it allows Android and iOS applications to render web content and execute ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found