File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -294,7 +294,17 @@ var NetworkTables = new function () {
294294 host = "ws:" ;
295295 }
296296
297- host += "//" + loc . host ;
297+ // If the websocket is being served from a different host allow users
298+ // to add a data-nt-host="" attribute to the script tag loading
299+ // Networktables.
300+ var ntHostElement = document . querySelector ( '[data-nt-host]' ) ;
301+ if ( ntHostElement ) {
302+ var ntHost = ntHostElement . getAttribute ( 'data-nt-host' ) ;
303+ host += "//" + ntHost ;
304+ } else {
305+ host += "//" + loc . host ;
306+ }
307+
298308 host += "/networktables/ws" ;
299309
300310 function createSocket ( ) {
Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ def open(self):
2626 self .ioloop = IOLoop .current ()
2727 self .ntserial = NTSerial (self .send_msg_threadsafe )
2828
29+ def check_origin (self , origin ):
30+ """
31+ Allow CORS requests
32+ """
33+ return True
34+
2935 def on_message (self , message ):
3036 if self .ntserial is not None :
3137 self .ntserial .process_update (message )
You can’t perform that action at this time.
0 commit comments