Hi Experts,
Good Morning,
Recently I got to learn about the AEM cloud environment variable, I understood how we can add a custom environment variable to an AEM cloud environment and use it on the OSGI services configuration. But I was wondering if we can somehow use the domain name, set for the AEM cloud instance. I did not find any reference about if there is any existing environment variable available for the domain name.
Please guide me if this is possible.
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @RP2777007
We get domain name from Request using APIs
private String getDomainFromURL() {
String url = request.getRequestURL().toString();
String hostComponent = "";
try {
URI uri = new URI(url);
hostComponent = uri.getHost();
} catch (URISyntaxException e) {
logger.debug("Unable to parse request URL");
}
}
For constructing URLs to say send in an email, you can use externalizer like https://medium.com/@toimrank/aem-externalizer-and-multisiteexternalizer-e3afad105b8
If the requirement is beyond these suggestions, please do let us know
Hello @RP2777007 -
hi @Tanika02 ,
I don't want to set the domain name, but I want to utilise the domain name and serve the endpoint of my API along with the domain. Usually we do it using Externalizer configuration, but in my case, we have two dev instances, and if we set configuration according to the environment and service type, it's taking one's domain to another.
Hello @RP2777007
We get domain name from Request using APIs
private String getDomainFromURL() {
String url = request.getRequestURL().toString();
String hostComponent = "";
try {
URI uri = new URI(url);
hostComponent = uri.getHost();
} catch (URISyntaxException e) {
logger.debug("Unable to parse request URL");
}
}
For constructing URLs to say send in an email, you can use externalizer like https://medium.com/@toimrank/aem-externalizer-and-multisiteexternalizer-e3afad105b8
If the requirement is beyond these suggestions, please do let us know
Hi @RP2777007 ,
As I understand, you have two dev instances and both should use a different domain for API.
You can create an OSGI config which should read domain from environment variables.
Now, it can be deployed to both AEM dev instances.
But, you can configure different domains for both AEM instances as environment variable. By this way, you will use same OSGI config but with different domains from environment variables.
I hope it helps!
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies