Skip to content Skip to sidebar Skip to footer

Accessing The Url Hostname From React Js

I'm trying to access the URL subdomain. Traditionally in JavaScript I'd do var full = window.location.host; var parts = full.split('.'); var subdomain = parts[0]; // ... However I

Solution 1:

This is isomorphic so if it is being processed server side so you cannot access the window.location.href

For server side, you will need to look at the underlying request object to get the hostname:

http://expressjs.com/en/api.html#req.hostname

Post a Comment for "Accessing The Url Hostname From React Js"