DEV: Fix livereload locally on https (#31776)

Previously, I was getting this error in the JS console:

```
livereload.js:2232 Mixed Content: The page at 'https://DOMAIN/' was
loaded over HTTPS, but attempted to connect to the insecure WebSocket
endpoint 'ws://DOMAIN:443/_lr/livereload'. This request has been blocked;
this endpoint must be available over WSS.
````

Adding a `https: true` option seems to fix the problem when running the
local server over an https proxy. (It'll be marked as `false` when the
protocol isn't https.)

This isn't just a warning, opening `/tests` is delayed about 10-20
seconds.

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Penar Musaraj
2025-03-13 09:05:39 -04:00
committed by GitHub
parent e8f4433872
commit d62db42f11

View File

@ -98,7 +98,7 @@ function updateScriptReferences({
// ember-cli-live-reload doesn't select ports correctly, so we use _lr/livereload directly
// (important for cloud development environments like GitHub CodeSpaces)
newElements.unshift(
`<script nonce="${nonce}">window.LiveReloadOptions = { "path": "_lr/livereload", "host": location.hostname, "port": location.port || (location.protocol === "https:" ? 443 : 80) }</script>`,
`<script nonce="${nonce}">window.LiveReloadOptions = { "path": "_lr/livereload", "host": location.hostname, "port": location.port || (location.protocol === "https:" ? 443 : 80), "https": location.protocol === "https:" }</script>`,
`<script async src="/_lr/livereload.js" nonce="${nonce}"></script>`
);
}