Hi Team,
I want to get the host name according to environments such as author , publisher and despatcher.
So I tried using java script like below.
window.location.hostname;
but my code is inside base page component. So it is saying window is not defined. Is there any way we can get the host name using HTL ?
Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @JakeCham
You can get server details in sightly from request object as below.
<div>The Scheme (http/https) is ${request.scheme}</div>
<div>The hostname(domain) is ${request.serverName}</div>
<div>The port is ${request.serverPort}</div>
<div>The request URI is ${request.requestURI}</div>
Regards
Shiv
Hi @JakeCham
You can get server details in sightly from request object as below.
<div>The Scheme (http/https) is ${request.scheme}</div>
<div>The hostname(domain) is ${request.serverName}</div>
<div>The port is ${request.serverPort}</div>
<div>The request URI is ${request.requestURI}</div>
Regards
Shiv
Thanks a lot!!
@JakeCham , although @Shiv_Prakash_Patel 's response is perfectly fine for your query.
If you are trying to create an absolute URL or externalLink. Try using Exernalizer service in your Sling Model (which can be tied to a runmode config) and then get it in sightly.
Externalizing URLs | Adobe Experience Manager
Externalizer (The Adobe AEM Quickstart and Web Application.)
Views
Likes
Replies