@@ -278,9 +278,14 @@ static int http_rest_post(http_request_t* request) {
278278
279279static int http_rest_app (http_request_t * request ) {
280280 const char * webhost = CFG_GetWebappRoot ();
281- const char * ourip = HAL_GetMyIPString (); //CFG_GetOurIP();
281+ // const char* ourip = HAL_GetMyIPString(); //CFG_GetOurIP();
282282 http_setup (request , httpMimeTypeHTML );
283- if (webhost && ourip ) {
283+ // if (webhost && ourip) {
284+ // we don't need to rely on any function here for our IP.
285+ // If this code is used, someone is accessing the webif, so we
286+ // know our ip (and port) inside the browser (JS "location").
287+ // Knowing/using the port from location.host is very usefull e.g. in simulator ;-)
288+ if (webhost ) {
284289 poststr (request , htmlDoctype );
285290
286291 poststr (request , "<head><title>" );
@@ -289,7 +294,7 @@ static int http_rest_app(http_request_t* request) {
289294
290295 poststr (request , htmlShortcutIcon );
291296 poststr (request , htmlHeadMeta );
292- hprintf255 (request , "<script>var root='%s',device='http://%s' ;</script>" , webhost , ourip );
297+ hprintf255 (request , "<script>var root='%s',device='http://'+location.host ;</script>" , webhost );
293298 hprintf255 (request , "<script src='%s/startup.js'></script>" , webhost );
294299 poststr (request , "</head><body></body></html>" );
295300 }
0 commit comments