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 181 views
1 answer 159 views
1 answer 136 views
1 answer 243 views
...