code-server: [Bug]: Image not showing up

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Brave
  • Local OS: MacOS Monterey
  • Remote OS: debian
  • Remote Architecture: amd54
  • code-server --version: 4.0.1 735c6da829535969ff7193c79379299e4a1cb9bc

Steps to Reproduce

  1. run code-server --bind-addr 0.0.0.0:443 --cert – /app
  2. Connect to the address
  3. Click an image

Expected

Image should be shown in editor

Actual

An SSL certificate error occurred when fetching the script. log.ts:313 ERR [Service Worker] registration DOMException: Failed to register a ServiceWorker for scope (‘https://–server–/’) with script (‘https://–server–/service-worker.js’): An SSL certificate error occurred when fetching the script.

Logs

No response

Screenshot/Video

No response

Does this issue happen in VS Code?

  • I cannot reproduce this in VS Code.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

Please note i’m running it in docker but 443 is exposed (via 8080 in my case).

This is a re-opening of https://github.com/coder/code-server/issues/4658

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 37 (14 by maintainers)

Most upvoted comments

I found a way to get Brave to work on MacOS. I used openssl s_client -connect localhost:8080 to retrieve the auto-generated (self-signed) certificate from the running code-server instance. I created a file with the extension .crt so I could import that key into Keychain Access.app. Then I used the search function in Keychain Access and double-clicked the new certificate to select “Always trust”. This enables all features other browsers don’t seem to have an issue with - images are shown, Webviews seem to work ok, Jupyter Notebooks run.

This might also be an acceptable workaround for https://github.com/coder/code-server/issues/5338 .

I am also seeing the ‘reconnect’ issue with code-server v4.0.2 – which is the latest release available at this time (18 Feb 2022)

I do hope a new release is provided soon, as in 2 week the new semester begins and I would like to upgrade the version the students are using.

Thank you for mentioning this issue there! Let’s hope this can be fixed “at the source”.

I was trying to allow insecure certificates from localhost with chrome://flags/#allow-insecure-localhost but that didn’t enable web-views.

Thanks for the details! That part sounds like it’s working as expected 🤔 We’ll have to dig into this.

That could well be related to https://github.com/coder/code-server/issues/4421 i suppose…

Hmm…okay we will have to dig into this again. Sorry y’all!

Thank you for the notes!

I am also using v4.2.0 now, seeing

Error loading webview: Error: Could not register service workers: SecurityError: Failed to register a ServiceWorker for scope ('https://.../static/out/vs/workbench/contrib/webview/browser/pre/') with script ('https://.../static/out/vs/workbench/contrib/webview/browser/pre/service-worker.js?v=4&vscode-resource-base-authority=vscode-resource.vscode-webview.net'): An SSL certificate error occurred when fetching the script..

This error comes up on localhost and when I connect from another computer.

BUT: I realised that Safari does show the image from another computer and on localhost - it doesn’t bring up the certificate problem. However Brave Browser Version 1.37.111 Chromium: 100.0.4896.79 (Official Build) (x86_64) shows the error above, even when “Shields down for this site” is selected.

I am using v4.2.0, still has this problem

I have install v4.2.0 in testing. Looks like the reconnect issue has been resolved as I am not seeing them any more. I will now look at update the images student use from v3.12.0 to v4.2.0

In the meantime, you can use version 3.9.1 if you really have to display images:

docker pull codercom/code-server:3.9.1