Read subdomain in java component

Hi all,

I’m trying to read the subdomain while in the doBeforeRender() of my HstComponent. But I can’t seem to find the actual url that is being requested. I only get parts of the content path, for example /content/gallery/buyitdirect/image.png. How can I get the actual requested url by the client, for localhost I’m expecting something like http://subdomain.localhost:3000/etc.

Thanks in advance!

brxm/ at d55ad59369171ab95ca2bfe939d32771121a9d92 · bloomreach/brxm · GitHub

Thanks. But same problem. I still get http://localhost:8080 instead of http://subdomain.localhost:8080.
Is there another option?

I think I found a solution. I use request.getHeader(“origin”) on the HttpServletRequest. Which gives me something like http://subdomain.localhost:3000. And then I substring the subdomain from it.

@machak Your answer pushed me in the right direction.