Hi, I modified my header with a link that opens another URL. The thing is that the URL varies depending on the environment (prod, test, dev) so I want to set the url dynamically depending on the context. Simple window.location.hostname does not work. And I had no luck finding any hint in the documentation. Looks like the header script runs in some different context than the browser but I can't figure out how to get to the url value that is in the browser. So can you advice me on how to get the hostname so that I can collect url that would look like this: "https://" + someFunctionThatGetsTheHostname + ":8443" ... My code:
a) There is typically no need to get the host name on the server side since all links / references should be relative, or at most absolute to the root of the host, which will be prepended by the host. The server should not have to deal with the host name, which might be completely different than what the browser called anyway due to proxying or other forwarding / URL rewriting mechanisms.
b) When you need environment specific URLs / host names (or any other sort of configuration / state), using the Surf configuration mechanism would provide a clean way of handling this without resorting to any host name guessing mechanics. Configuration is defined in share-config.xml / share-config-custom.xml (e.g. repository-url for Share to create WebDAV links) and can be retrieved in server-side JS code like this. There technically is no schema at all for the share-config.xml, so you can define whatever sub-elements you like to a custom config section of your own. The main differentiation is made via the "condition" on the <config> element which is the entrypoint to a so called "config section".