EDIT: It looks like I was making a false assumption that the reason why my code was not working (I was getting AudioWorkletProcessor
is undefined) was because the context was insecure… but I will leave this question up since the general question and answer is still useful).
On Mac, I am trying to test some website javascript that involves AudioWorkletProcessor
.
Apparently this class is "only available in a secure context."
I’m assuming this means that the browser running the javascript that contains it must believe it is secure (https) with a valid certificate.
I am testing using firebase serve which makes the site available at localhost:5000 but it doesn’t use or offer https.
As far as I understand my options are:
-
Use ngrok to create an https tunnel to localhost:5000
Cannot, because it is a paid feature and I don’t want to get into that. -
Use http-server like this:
openssl req -nodes -new -x509 -keyout server.key -out server.cert
http-server -S -C server.cert -K server.key -p 5000 ./public
… but this does not work because the cert is not valid, so we would need add the bad cert to my keychain which I also don’t like.
Is there some other way to test javascript that uses classes that require a secure context? Maybe some kind of fake/test browser??
Thanks.
2
Answers
Cloudflare provide free tunnel. You can try with it.
Document: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/
Install cloudflare tunnel on your local, publish your local with Cloudflare’s domain. (…. trycloudflare.com)
From https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts
You can verify this through the
window.isSecureContext
property.