Unable to run dist builds with VS Code Live Server recently

I tried doing a production build using latest Needle Exporter, in the past I was fine to use Live Server for VS Code to run the builds locally to test them, recently it tries to open them at where I get the error
This site can’t provide a secure connection127.0.0.1 sent an invalid response.
Try running Windows Network Diagnostics.

Original Post on Discord

by user 103054507105067008

Could also be related to the vite-plugin-mkcert I used for a while but that was used in this project and is only in devDependencies

by user 103054507105067008

In Vite Config I did this which might be the cause although I recall BasicSsl not working well with mkcert

       plugins: [

Trying a build with it uncommented

by user 103054507105067008

Right, so it was this in the html

    if(location.protocol == 'http:' && location.host.indexOf('localhost') < 0) location.protocol = 'https:';

by user 103054507105067008

Which I got from @herbst🌵 here Discord
Is there a way to prevent that script from interfering with VS Code Live Server? Obviously is fine when running on an actual server under a domain

by user 103054507105067008

Why are you using VS Code live server? You can also just run npm run serve in the project

Feel free to let us know when you find a workaround for that (potential) issue in live server, but we can’t support on each and any external tool anyone might use

(I think you need to tell the live server that it should use HTTPS too and that’s it)

Will close for now just wanted to document it as I searched ERR_SSL_PROTOCOL_ERROR hoping to see if anyone else hit that here

by user 103054507105067008

Well it’s pretty much that, an SSL error - Live Server by default only uses http and you need to configure it to use https, unrelated to Needle Engine :slightly_smiling_face:

And you should use https, always, because otherwise you don’t have WebXR and other advanced web APIs available.

We have configured out server to enforce https, just was a dev environment issue I had that script in for luckily

by user 103054507105067008

Same for localhost. Just use https - yes, it may be more setup work depending on what tool (e.g. seems like Live Server needs extra config) but you’ll save you and your team lots of headache :slightly_smiling_face: