> Browsers deal with this by considering localhost a "secure context"
Broadly yes, except Safari which still sometimes doesn't: https://bugs.webkit.org/show_bug.cgi?id=171934
(Not relevant to this case, but eugh it's a very annoying exception)
[1] https://developer.mozilla.org/en-US/docs/Web/Security/Secure...
[2] https://developer.mozilla.org/en-US/docs/Web/Security/Secure...