react check if localhost 1

react check if localhost

if (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "") {
    alert("It's a local server!");
}

Here is what the above code is Doing:
1. We’re checking if the hostname is localhost, 127.0.0.1, or an empty string.
2. If it is, we’re alerting the user.

Similar Posts