'HTTP request from secure page

I have a simple web page that runs a javascript QR code scanner that needs to send the scanned codes to a local laptop. The communication here really only needs to go one way since from the web page I don't really care about the laptop's responses.

So I tried serving the web page from the laptop itself, but access to the camera requires a secure web page so the laptop would have to serve via HTTPS. So I looked into certs, but because I need to deploy the desktop application across a number of laptops this seemed like a bad idea with trying to manage certs securely.

So then I tried serving the web app from GCP's Cloud Run so that the web page is secure, but since it needs to talk to the laptop I tried making HTTP requests directly to the laptop server from the web page, but that got blocked for mixed content security issues. So I read about that in this answer https://stackoverflow.com/a/58828432/8516516, but the options here don't seem to work for me since I can't move the "old site" (e.g. desktop application) to HTTPS for the cert issues above, I can't use HTTP because I need access to the camera, and the proxy doesn't seem like it would work locally.

If I understand the insecurity in using HTTP on a HTTPS page it has to do with loading insecure content and scripts on the page, but in this case I only want to push text out to the local server on the laptop and not load anything in the app or care about the responses. And in the past using an iframe was an option, but that has been shut down.

Is there some way that I can still make requests locally even though it is insecure? Or am I approaching this problem all wrong and need to rethink this? What is the typical way that something like this is structured?

My other thought is open a websocket from the local laptop to Cloud Run and then pass the data from the web page back to Cloud Run and then forward it on the laptop. Is that the more appropriate method of handling this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source