lumeland / lume

🔥 Static site generator for Deno 🦕
https://lume.land
MIT License
1.79k stars 77 forks source link

Live reload: Detect if https:// or http:// before deciding to use `ws://` or `wss://` #316

Closed onionhammer closed 1 year ago

onionhammer commented 1 year ago

Enter your suggestions in details:

For dev environments like codespaces, in-browser, github will generate an HTTPS URL or developing "in the cloud", but it will block "ws://"

(index):75 Mixed Content: The page at 'https://someurl-3000.preview.app.github.dev/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://someurl-3000.preview.app.github.dev/'. This request has been blocked; this endpoint must be available over WSS.

oscarotero commented 1 year ago

Good catch. I'll work on that. I guess it's only detecting the protocol in the client side javascript (here: https://github.com/lumeland/lume/blob/master/middlewares/reload_client.js#L10) right?

Something like:

const protocol = document.location.protocol === "https:" ? "wss://" : "ws://";
onionhammer commented 1 year ago

Yeah that was my thought