As my website is in local network with no connection to Internet, I have to host mitm.html as well as sw.js on my server. I changed the links to point to my server addess.
when you use an ip address instead of localhost then the web context is considered insecure (unless you use https)
you have 4 options:
Create a self certificate and make your page secure.
Treat given (insecure) origins as secure origins in your browser. there are different way to do it in different browsers... chrome://flags/#unsafely-treat-insecure-origin-as-secure
host mitm.html on a secure site but make mitm.html cachable so it works offline. see for more background #126 (this requires a internet connection once to install StreamSaver)
Point localhost to 192.168.xxx.xxx in your host file so that when you write http://localhost:1234 you will actually request the page from 192.168.xxx.xxx
As my website is in local network with no connection to Internet, I have to host mitm.html as well as sw.js on my server. I changed the links to point to my server addess.
It worked fine when I debug locally with 'http://localhost:1234', but when I use 'http://192.168.XXX.XXX:1234', the channel.port1.onmessage seemed not called.
I wonder if MessageChannel or stream couldn't be used in insecure website. Is there a way to work around this?