How to check with if connection is localhost in JavaScript

1 Answer

0 votes
if (location.hostname === "localhost" || location.hostname === "127.0.0.1")
    console.log("localhost");
else
    console.log("not localhost");
 





  
/*
run:
  
"not localhost"
  
*/

 



answered Apr 28, 2022 by avibootz

Related questions

1 answer 284 views
1 answer 272 views
1 answer 230 views
1 answer 366 views
...