Skip to content

Markdown Preview is not working #4421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
benjcabalona1029 opened this issue Nov 1, 2021 · 38 comments
Closed

Markdown Preview is not working #4421

benjcabalona1029 opened this issue Nov 1, 2021 · 38 comments

Comments

@benjcabalona1029
Copy link

Issue is similar to #296 The fix in this issue is not applicable to me I think since I'm not running behind nginx.

  • Web Browser: Google Chrome
  • Local OS: Windows 10
  • Remote OS: Ubuntu 20.04

Steps to Reproduce

  1. Open any md file.
  2. Try previewing the document.

Nothing in the code-server logs, But on dev tools,

Uncaught (in promise) Error: Service Workers are not enabled. Webviews will not work. Try disabling private/incognito mode.
    at main.js:115
    at new Promise (<anonymous>)
    at main.js:115

I'm not accesing it in incognito mode.

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 1, 2021

@benjcabalona1029 you need to enable service workers in order for the markdown preview to work. Are you serving code-server via HTTPS?

@benjcabalona1029
Copy link
Author

@jsjoeio Thank yor for your comment. How do i enable the service workers? No, I'm not serving it in https.

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 3, 2021

No, I'm not serving it in https

There's your issue. You'll need to serve it via HTTPS and that will allow your browser to enable service workers automatically I believe.

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 3, 2021

I'm going to close this since this is related to your environment but feel free to open a Discussion if you need more help or have a question about enabling HTTPS. See the docs here for more info.

@jsjoeio jsjoeio closed this as completed Nov 3, 2021
@benjcabalona1029
Copy link
Author

Hi @jsjoeio I tried serving it with the --link for it to be served in HTTPS, however the preview is still not working.

I get a new error,

  ERR [UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//"): Error: [UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")
    at b (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:70:77397)
    at new p (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:70:78038)
    at new m (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:70:79686)
    at Function.from (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:70:79103)
    at https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1271:14766
    at String.replace (<anonymous>)
    at _.rewriteVsCodeResourceUrls (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1271:14654)
    at _.set html [as html] (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1271:14307)
    at https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1226:30501
    at b.withWebview (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1226:31874)

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 4, 2021

Uhh...I have yet to see this error 🤔 @code-asher any ideas?

@code-asher
Copy link
Member

code-asher commented Nov 10, 2021 via email

@benjcabalona1029
Copy link
Author

Okay, I'll try to update it once we have a new release. Can we reopen this issue? @jsjoeio

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 10, 2021

Good call! You got it

@jsjoeio jsjoeio reopened this Nov 10, 2021
@krenny
Copy link

krenny commented Nov 11, 2021

Might be unrelated but I have seen Issues like that while using private/incognito mode.

For some odd reasons serverice workers won't start in incognito...

Edit: this seems only be true for firefox

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 12, 2021

For some odd reasons serverice workers won't start in incognito...

I believe service workers are disabled in incognito in Firefox (IIRC)

@austinbutler
Copy link

austinbutler commented Jan 19, 2022

Markdown preview is also not working for me since upgrading to 4.0.1 it seems (from 3.x). I use SSH forwarding, and in the Chrome "Application" tab I see two service workers are green with status "activated and is running." Triggering markdown preview results in no new system logs or console logs, just shows "Activating Extensions..." then nothing happens.

Console log
 INFO [Service Worker] registered
webWorkerExtensionHost.ts:211 GET http://localhost:8081/static/stable/out/vs/workbench/services/extensions/worker/httpWebWorkerExtensionHostIframe.html?&vscodeWebWorkerExtHostId=f5c546d0-a5ec-4bbe-8289-7c3da99f2316 404 (Not Found)
_startInsideIframe @ webWorkerExtensionHost.ts:211
start @ webWorkerExtensionHost.ts:138
Qr @ extensionHostManager.ts:124
_createInstance @ instantiationService.ts:110
createInstance @ instantiationService.ts:76
g @ extensionHostManager.ts:57
(anonymous) @ abstractExtensionService.ts:625
_startExtensionHosts @ abstractExtensionService.ts:624
_initialize @ abstractExtensionService.ts:521
(anonymous) @ extensionService.ts:79
Promise.then (async)
Hl @ extensionService.ts:77
_createInstance @ instantiationService.ts:110
_createServiceInstance @ instantiationService.ts:230
_createServiceInstanceWithOwner @ instantiationService.ts:219
_createAndCacheServiceInstance @ instantiationService.ts:208
_safeCreateAndCacheServiceInstance @ instantiationService.ts:151
_getOrCreateServiceInstance @ instantiationService.ts:135
_createInstance @ instantiationService.ts:88
createInstance @ instantiationService.ts:76
acquireInstantiationService @ configurationService.ts:457
(anonymous) @ workbench.ts:212
invokeFunction @ instantiationService.ts:61
initServices @ workbench.ts:206
startup @ workbench.ts:138
open @ web.main.ts:103
abstractExtensionService.ts:927 [ms-python.python]: Cannot register 'python.pythonPath'. This property is already registered.
_logMessageInConsole @ abstractExtensionService.ts:927
_handleExtensionPointMessage @ abstractExtensionService.ts:878
X @ abstractExtensionService.ts:852
_msg @ extensionsRegistry.ts:37
warn @ extensionsRegistry.ts:50
g @ configurationExtensionPoint.ts:237
h @ configurationExtensionPoint.ts:212
(anonymous) @ configurationExtensionPoint.ts:283
_handle @ extensionsRegistry.ts:143
acceptUsers @ extensionsRegistry.ts:134
_handleExtensionPoint @ abstractExtensionService.ts:912
_doHandleExtensionPoints @ abstractExtensionService.ts:858
_scanAndHandleExtensions @ extensionService.ts:223
await in _scanAndHandleExtensions (async)
_initialize @ abstractExtensionService.ts:525
await in _initialize (async)
(anonymous) @ extensionService.ts:79
Promise.then (async)
Hl @ extensionService.ts:77
_createInstance @ instantiationService.ts:110
_createServiceInstance @ instantiationService.ts:230
_createServiceInstanceWithOwner @ instantiationService.ts:219
_createAndCacheServiceInstance @ instantiationService.ts:208
_safeCreateAndCacheServiceInstance @ instantiationService.ts:151
_getOrCreateServiceInstance @ instantiationService.ts:135
_createInstance @ instantiationService.ts:88
createInstance @ instantiationService.ts:76
acquireInstantiationService @ configurationService.ts:457
(anonymous) @ workbench.ts:212
invokeFunction @ instantiationService.ts:61
initServices @ workbench.ts:206
startup @ workbench.ts:138
open @ web.main.ts:103
await in open (async)
fe @ web.main.ts:413
n @ workbench.web.api.ts:664
(anonymous) @ workbench.ts:565
(anonymous) @ workbench.ts:603
i._invokeFactory @ loader.js:1185
i.complete @ loader.js:1195
i._onModuleComplete @ loader.js:1821
i._onModuleComplete @ loader.js:1833
i._resolve @ loader.js:1781
i.defineModule @ loader.js:1424
o @ loader.js:1709
_ @ loader.js:2208
i._invokeFactory @ loader.js:1185
i.complete @ loader.js:1195
i._onModuleComplete @ loader.js:1821
i._onModuleComplete @ loader.js:1833
i._resolve @ loader.js:1781
i.defineModule @ loader.js:1424
v @ loader.js:1871
(anonymous) @ workbench.nls.js:7
abstractExtensionService.ts:927 [ms-python.python]: Cannot register 'python.venvPath'. This property is already registered.
_logMessageInConsole @ abstractExtensionService.ts:927
_handleExtensionPointMessage @ abstractExtensionService.ts:878
X @ abstractExtensionService.ts:852
_msg @ extensionsRegistry.ts:37
warn @ extensionsRegistry.ts:50
g @ configurationExtensionPoint.ts:237
h @ configurationExtensionPoint.ts:212
(anonymous) @ configurationExtensionPoint.ts:283
_handle @ extensionsRegistry.ts:143
acceptUsers @ extensionsRegistry.ts:134
_handleExtensionPoint @ abstractExtensionService.ts:912
_doHandleExtensionPoints @ abstractExtensionService.ts:858
_scanAndHandleExtensions @ extensionService.ts:223
await in _scanAndHandleExtensions (async)
_initialize @ abstractExtensionService.ts:525
await in _initialize (async)
(anonymous) @ extensionService.ts:79
Promise.then (async)
Hl @ extensionService.ts:77
_createInstance @ instantiationService.ts:110
_createServiceInstance @ instantiationService.ts:230
_createServiceInstanceWithOwner @ instantiationService.ts:219
_createAndCacheServiceInstance @ instantiationService.ts:208
_safeCreateAndCacheServiceInstance @ instantiationService.ts:151
_getOrCreateServiceInstance @ instantiationService.ts:135
_createInstance @ instantiationService.ts:88
createInstance @ instantiationService.ts:76
acquireInstantiationService @ configurationService.ts:457
(anonymous) @ workbench.ts:212
invokeFunction @ instantiationService.ts:61
initServices @ workbench.ts:206
startup @ workbench.ts:138
open @ web.main.ts:103
await in open (async)
fe @ web.main.ts:413
n @ workbench.web.api.ts:664
(anonymous) @ workbench.ts:565
(anonymous) @ workbench.ts:603
i._invokeFactory @ loader.js:1185
i.complete @ loader.js:1195
i._onModuleComplete @ loader.js:1821
i._onModuleComplete @ loader.js:1833
i._resolve @ loader.js:1781
i.defineModule @ loader.js:1424
o @ loader.js:1709
_ @ loader.js:2208
i._invokeFactory @ loader.js:1185
i.complete @ loader.js:1195
i._onModuleComplete @ loader.js:1821
i._onModuleComplete @ loader.js:1833
i._resolve @ loader.js:1781
i.defineModule @ loader.js:1424
v @ loader.js:1871
(anonymous) @ workbench.nls.js:7
mime.ts:64 Overwriting extension <<.hbs>> to now point to mime <<text/x-handlebars>>
(anonymous) @ mime.ts:64
v @ mime.ts:58
_mergeLanguage @ languagesRegistry.ts:191
_registerLanguage @ languagesRegistry.ts:165
_registerLanguages @ languagesRegistry.ts:120
_initializeFromRegistry @ languagesRegistry.ts:114
(anonymous) @ languagesRegistry.ts:96
fire @ event.ts:577
setDynamicLanguages @ modesRegistry.ts:50
(anonymous) @ workbenchModeService.ts:139
_handle @ extensionsRegistry.ts:143
acceptUsers @ extensionsRegistry.ts:134
_handleExtensionPoint @ abstractExtensionService.ts:912
_doHandleExtensionPoints @ abstractExtensionService.ts:858
_scanAndHandleExtensions @ extensionService.ts:223
await in _scanAndHandleExtensions (async)
_initialize @ abstractExtensionService.ts:525
await in _initialize (async)
(anonymous) @ extensionService.ts:79
Promise.then (async)
Hl @ extensionService.ts:77
_createInstance @ instantiationService.ts:110
_createServiceInstance @ instantiationService.ts:230
_createServiceInstanceWithOwner @ instantiationService.ts:219
_createAndCacheServiceInstance @ instantiationService.ts:208
_safeCreateAndCacheServiceInstance @ instantiationService.ts:151
_getOrCreateServiceInstance @ instantiationService.ts:135
_createInstance @ instantiationService.ts:88
createInstance @ instantiationService.ts:76
acquireInstantiationService @ configurationService.ts:457
(anonymous) @ workbench.ts:212
invokeFunction @ instantiationService.ts:61
initServices @ workbench.ts:206
startup @ workbench.ts:138
open @ web.main.ts:103
await in open (async)
fe @ web.main.ts:413
n @ workbench.web.api.ts:664
(anonymous) @ workbench.ts:565
(anonymous) @ workbench.ts:603
i._invokeFactory @ loader.js:1185
i.complete @ loader.js:1195
i._onModuleComplete @ loader.js:1821
i._onModuleComplete @ loader.js:1833
i._resolve @ loader.js:1781
i.defineModule @ loader.js:1424
o @ loader.js:1709
_ @ loader.js:2208
i._invokeFactory @ loader.js:1185
i.complete @ loader.js:1195
i._onModuleComplete @ loader.js:1821
i._onModuleComplete @ loader.js:1833
i._resolve @ loader.js:1781
i.defineModule @ loader.js:1424
v @ loader.js:1871
(anonymous) @ workbench.nls.js:7
mime.ts:64 Overwriting extension <<.handlebars>> to now point to mime <<text/x-handlebars>>
(anonymous) @ mime.ts:64
v @ mime.ts:58
_mergeLanguage @ languagesRegistry.ts:191
_registerLanguage @ languagesRegistry.ts:165
_registerLanguages @ languagesRegistry.ts:120
_initializeFromRegistry @ languagesRegistry.ts:114
(anonymous) @ languagesRegistry.ts:96
fire @ event.ts:577
setDynamicLanguages @ modesRegistry.ts:50
(anonymous) @ workbenchModeService.ts:139
_handle @ extensionsRegistry.ts:143
acceptUsers @ extensionsRegistry.ts:134
_handleExtensionPoint @ abstractExtensionService.ts:912
_doHandleExtensionPoints @ abstractExtensionService.ts:858
_scanAndHandleExtensions @ extensionService.ts:223
await in _scanAndHandleExtensions (async)
_initialize @ abstractExtensionService.ts:525
await in _initialize (async)
(anonymous) @ extensionService.ts:79
Promise.then (async)
Hl @ extensionService.ts:77
_createInstance @ instantiationService.ts:110
_createServiceInstance @ instantiationService.ts:230
_createServiceInstanceWithOwner @ instantiationService.ts:219
_createAndCacheServiceInstance @ instantiationService.ts:208
_safeCreateAndCacheServiceInstance @ instantiationService.ts:151
_getOrCreateServiceInstance @ instantiationService.ts:135
_createInstance @ instantiationService.ts:88
createInstance @ instantiationService.ts:76
acquireInstantiationService @ configurationService.ts:457
(anonymous) @ workbench.ts:212
invokeFunction @ instantiationService.ts:61
initServices @ workbench.ts:206
startup @ workbench.ts:138
open @ web.main.ts:103
await in open (async)
fe @ web.main.ts:413
n @ workbench.web.api.ts:664
(anonymous) @ workbench.ts:565
(anonymous) @ workbench.ts:603
i._invokeFactory @ loader.js:1185
i.complete @ loader.js:1195
i._onModuleComplete @ loader.js:1821
i._onModuleComplete @ loader.js:1833
i._resolve @ loader.js:1781
i.defineModule @ loader.js:1424
o @ loader.js:1709
_ @ loader.js:2208
i._invokeFactory @ loader.js:1185
i.complete @ loader.js:1195
i._onModuleComplete @ loader.js:1821
i._onModuleComplete @ loader.js:1833
i._resolve @ loader.js:1781
i.defineModule @ loader.js:1424
v @ loader.js:1871
(anonymous) @ workbench.nls.js:7
I @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:472
_invokeHandler @ rpcProtocol.ts:457
_receiveRequest @ rpcProtocol.ts:373
_receiveOneMessage @ rpcProtocol.ts:295
(anonymous) @ rpcProtocol.ts:160
fire @ event.ts:577
fire @ ipc.net.ts:511
_receiveMessage @ ipc.net.ts:869
(anonymous) @ ipc.net.ts:708
fire @ event.ts:577
acceptChunk @ ipc.net.ts:284
(anonymous) @ ipc.net.ts:245
(anonymous) @ browserSocketFactory.ts:197
fire @ event.ts:577
C._fileReader.onload @ browserSocketFactory.ts:81
webWorkerExtensionHost.ts:184 The Web Worker Extension Host did not start in 60s, that might be a problem.

Not sure if related or a new issue.

@tlw-ray
Copy link

tlw-ray commented Feb 9, 2022

When use http://127.0.0.1 or http://localhost code-server's markdown-preview-enhanced preview should worked fine, otherwise use http://ip markdown-preview-enhanced preview is not working.

VSCode markdown Plugin: shd101wyy.markdown-preview-enhanced
Explorer: firefox or chrome
CodeServer: v4.0.2

@tlw-ray
Copy link

tlw-ray commented Feb 9, 2022

Chrome Console:

VM6:1 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'sha256-cb2sg39EJV8ABaSNFfWu/ou8o1xVXYK7jp90oZ9vpcg=' http: https:". Either the 'unsafe-inline' keyword, a hash ('sha256-4sNwvmWshEzqW5S25HVAak+QIUCkjYSbAaQ7Ieh/EDA='), or a nonce ('nonce-...') is required to enable inline execution.

t @ VM6:1
i @ VM6:1
a @ VM6:1
(anonymous) @ VM6:1
VM31 main.js:115 Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')
    at VM31 main.js:115
(anonymous) @ VM31 main.js:115
VM31 main.js:115 Uncaught (in promise) Error: Service Workers are not enabled. Webviews will not work. Try disabling private/incognito mode.
    at VM31 main.js:115
    at new Promise (<anonymous>)
    at VM31 main.js:115
(anonymous) @ VM31 main.js:115
(anonymous) @ VM31 main.js:115

@jsjoeio
Copy link
Contributor

jsjoeio commented Feb 9, 2022

You need to be on HTTPS for it work

@tlw-ray
Copy link

tlw-ray commented Feb 11, 2022

Thanks , but Markdown-preview still can't appear after using https, and the following prompt is 'Activating Extensions...',
Chrome Console log :
VM147:1 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'sha256-HuyBNEnumn/Bw3njx2R0EXAv9HicWHLQQd9NJ9ruyrk=' 'sha256-hwmTfNWB8XRD349z+U9G9OefbQgy28G4Xs7WyYCCXgM=' 'sha256-yxwQ9j8YGPsfU554CNGiSCW08z5yqDVvuQmssjoPsm8=' 'sha256-cb2sg39EJV8ABaSNFfWu/ou8o1xVXYK7jp90oZ9vpcg='". Either the 'unsafe-inline' keyword, a hash ('sha256-4sNwvmWshEzqW5S25HVAak+QIUCkjYSbAaQ7Ieh/EDA='), or a nonce ('nonce-...') is required to enable inline execution.

t @ VM147:1
i @ VM147:1
a @ VM147:1
(anonymous) @ VM147:1
VM147:1 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'sha256-cb2sg39EJV8ABaSNFfWu/ou8o1xVXYK7jp90oZ9vpcg=' https:". Either the 'unsafe-inline' keyword, a hash ('sha256-4sNwvmWshEzqW5S25HVAak+QIUCkjYSbAaQ7Ieh/EDA='), or a nonce ('nonce-...') is required to enable inline execution.

@tlw-ray
Copy link

tlw-ray commented Feb 11, 2022

2022-02-12 00-16-56 的屏幕截图

@jsjoeio
Copy link
Contributor

jsjoeio commented Feb 11, 2022

@tlw-ray hmm I'm not sure what that could be. Your error message looks very odd. You're using 4.0.2? Can you try clearing your cache maybe?

It's working for me.

image

@tlw-ray
Copy link

tlw-ray commented Feb 12, 2022

@jsjoeio, hi, I'm finding the cause of the problem.

case1: Start code-server-4.0.2 with out cert. (I only using this version server)

When accessing the server via http://127.0.0.1 or http://localhost, typing navigator.serviceWorker in the browser's console, return a ServiceWorkerContainer object. At this point, markdown preview is ok.

Accssing via http://ip, such options return null. Of course, the markdown preview is invalid. Explorer console log warnning (Https may be needed at this point):

main.js:400 Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')
    at main.js:400
(anonymous) @ main.js:400
main.js:204 Uncaught (in promise) Error: Service Workers are not enabled. Webviews will not work. Try disabling private/incognito mode.
    at main.js:204
    at new Promise (<anonymous>)
    at main.js:202

case2: Start with cert and cert-key, and let explorer trust the self cert ROOTCA(https no warning in explorer).

Access via https://domain, such options return the ServiceWorkerContainer fine, when open markdown preview a waiting prompt for Activating Service... appears in the status bar in the lower left. But the preview panel(iframe) is always blank, browser console outputs the logs in gray(seen that it is communicating with the background, but I think this feature supposed to run inside the browser):

 INFO [remote-connection][ExtensionHost][b984b…][reconnect] starting reconnecting loop. You can get more information with the trace log level.
log.ts:301  INFO [remote-connection][ExtensionHost][b984b…][reconnect] resolving connection...
log.ts:301  INFO [remote-connection][ExtensionHost][b984b…][reconnect] connecting to example.com:9070...
log.ts:301  INFO [remote-connection][ExtensionHost][b984b…][reconnect] reconnected!

@tlw-ray
Copy link

tlw-ray commented Feb 12, 2022

Note the gray log~ Is this normal?

2022-02-12 17-45-22 的屏幕截图

@gogobd
Copy link

gogobd commented Feb 12, 2022

Although 4.0.2 fixed some http / https related issues for me it did not fix Markdown preview via http (and hostname).

@jsjoeio
Copy link
Contributor

jsjoeio commented Feb 14, 2022

Note the gray log~ Is this normal?

Ah maybe I'm slow, but what am I looking at here?

case2: Start with cert and cert-key, and let explorer trust the self cert ROOTCA(https no warning in explorer).

That looks like #4773 which should be fixed in 4.0.3

@tlw-ray
Copy link

tlw-ray commented Feb 15, 2022

Great~

@Water-Ghost
Copy link

Still not works for me

@jsjoeio
Copy link
Contributor

jsjoeio commented Feb 24, 2022

@Cleanairdreaming are you using HTTPS?

@ksbalajee
Copy link

Hi @jsjoeio ,
I'm trying to build a react application with the code server as an iframe. The code server is served over HTTPS and when I tried to launch my react application in my local (http://localhost:3000), I don't see any issues. However, when I deploy my react application to a domain (http://my-app.com) that's when I'm getting the error that the OP posted and also a popup saying that
code-server is being accessed in an insecure context. Web views, the clipboard, and other functionality may not work as expected.
Also when I try to open the code server URL from the iframe to a new tab, I don't see this issue. Do I need to host my react application in HTTPS as well?

image

code-server: v4.3.0
Code: 1.65.2
Commit: Unknown
Date: 2022-04-14T21:04:05.402Z
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

@jsjoeio
Copy link
Contributor

jsjoeio commented Jul 18, 2022

Can you deploy it to HTTPS? I believe many services offer this for free. Other than that, there isn't much we can do since this is a browser limitation

@gogobd
Copy link

gogobd commented Jul 19, 2022

Maybe #5338 is related?

@ksbalajee
Copy link

Can you deploy it to HTTPS? I believe many services offer this for free. Other than that, there isn't much we can do since this is a browser limitation

I deployed it in HTTPS and it works as expected. Thanks @jsjoeio

@jsjoeio
Copy link
Contributor

jsjoeio commented Aug 1, 2022

awesome! i'm going to close this for now then.

@jsjoeio jsjoeio closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2022
@willzhang
Copy link

willzhang commented Aug 4, 2022

You can config https, it's easy: https://coder.com/docs/code-server/latest/guide#using-lets-encrypt-with-caddy

@gogobd
Copy link

gogobd commented Aug 4, 2022

Is it just not planned to allow code server to work properly with the certificates it creates when started with ’--cert’?

@Water-Ghost
Copy link

@jsjoeio It worked, when I add --cert. The link worked perfectly when use safari, the only thing need to do is to trust the certificat. Chrome not worked, I turn to Chrome Canary, and start it with --ignore-certificate-errors --ignore-urlfetcher-cert-request, finally it worked.

@gogobd
Copy link

gogobd commented Aug 4, 2022

The certs are being created with mkcert i wonder if chrome starts to work if you install mkcert on your host system?

@code-asher
Copy link
Member

By working properly do we mean Chrome is not letting you accept the self-signed certificate? When I try I get "your connection is not private" (as expected) then I can accept the certificate anyway by going to advanced > proceed on the page.

@gogobd
Copy link

gogobd commented Aug 10, 2022

When i do "advanced.../proceed..." i still get webview errors and most cool features don't work as expected :-/

@code-asher
Copy link
Member

code-asher commented Aug 10, 2022

Ohhhhh right I remember now that Chrome started rejecting the certificate for service workers even if you accept the certificate on that page. I am not sure if there is anything we can do from code-server's side on this unfortunately. I think this is just a decision they made on the browser side so we are kinda stuck with it.

It might be wise to output some text when using --cert describing the limitations or maybe show a message in-browser if we can about the issue. Or maybe the move is to deprecate --cert and recommend something like mkcert?

Although personally to me it feels like a bug so maybe there is something upstream about it.

@code-asher
Copy link
Member

Interestingly Firefox does seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants