8000 webrepl.html: Add warning on accessing over HTTPS. · micropython/webrepl@aca760d · GitHub
[go: up one dir, main page]

Skip to content

Commit aca760d

Browse files
mcauserPaul Sokolovsky
authored and
Paul Sokolovsky
committed
webrepl.html: Add warning on accessing over HTTPS.
Per web content policy, accessing page over HTTPS requires it to use wss: for WebSocket access, but we don't support SSL WebSockets for WebREPL.
1 parent f8dbf12 commit aca760d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

webrepl.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,28 @@
106106
cursorBlink: false
107107
});
108108
term.open(document.getElementById("term"));
109+
show_https_warning();
109110
};
110111
window.addEventListener('resize', function() {
111112
var size = calculate_size(self);
112113
term.resize(size[0], size[1]);
113114
});
114115
}).call(this);
115116

117+
function show_https_warning() {
118+
if (window.location.protocol == 'https:') {
119+
var warningDiv = document.createElement('div');
120+
warningDiv.style.cssText = 'background:#f99;padding:5px;margin-bottom:10px;line-height:1.5em;text-align:center';
121+
warningDiv.innerHTML = [
122+
'At this time, the WebREPL client cannot be accessed over HTTPS connections.',
123+
'Use a HTTP connection, eg. <a href="http://micropython.org/webrepl/">http://micropython.org/webrepl/</a>.',
124+
'Alternatively, download the files from <a href="https://github.com/micropython/webrepl">GitHub</a> and run them locally.'
125+
].join('<br>');
126+
document.body.insertBefore(warningDiv, document.body.childNodes[0]);
127+
term.resize(term.cols, term.rows - 7);
128+
}
129+
}
130+
116131
function button_click() {
117132
if (connected) {
118133
ws.close();

0 commit comments

Comments
 (0)
0