<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting a URL from the browser in Share in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133769#M36021</link>
    <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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. &lt;A href="https://github.com/Alfresco/share/blob/ee2b96a08a0b419661317b38400a4b5ecc7e5346/packaging/distribution/src/main/resources/web-extension-samples/share-config-custom.xml#L215" target="_self" rel="nofollow noopener noreferrer"&gt;repository-url for Share to create WebDAV links&lt;/A&gt;) and can be retrieved in server-side JS code &lt;A href="https://github.com/Alfresco/share/blob/ee2b96a08a0b419661317b38400a4b5ecc7e5346/share/src/main/resources/alfresco/site-webscripts/org/alfresco/share/imports/document-library.lib.js#L473" target="_self" rel="nofollow noopener noreferrer"&gt;like this&lt;/A&gt;. 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 &amp;lt;config&amp;gt; element which is the entrypoint to a so called "config section".&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jun 2021 10:40:48 GMT</pubDate>
    <dc:creator>afaust</dc:creator>
    <dc:date>2021-06-14T10:40:48Z</dc:date>
    <item>
      <title>Getting a URL from the browser in Share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133766#M36018</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I modified my header with a link that opens&amp;nbsp; 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.&lt;BR /&gt;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.&lt;BR /&gt;So can you advice me on how to get the hostname so that I can collect url that would look like this:&lt;BR /&gt;"https://" + someFunctionThatGetsTheHostname + ":8443" ...&lt;BR /&gt;My code:&lt;/P&gt;&lt;PRE&gt;function getTicket() {
    var myTicket = "";
    var result = remote.call("/custom/ticket");
    if (result.status == 200) {
        var myTicket = eval('(' + result + ')').ticket;
    }
    return myTicket;
}

model.jsonModel = {
    widgets: [{
        id: "DOC_FILTER_PAGE_TITLE",
        name: "alfresco/header/SetTitle",
        config: {
            title: "XY"
        }
    },
        {
            id: "DOC_FILTER_HORIZONTAL_WIDGET_LAYOUT",
            name: "alfresco/layout/HorizontalWidgets",
            config: {
                widgetWidth: 100,
                widgets: [
                     {
                         id: "DOC_FILTER_IFRAME",
                         name: "alfresco/integration/IFrame",
                         config: {
                            src: "https://" + &lt;STRONG&gt;window.location.hostname&lt;/STRONG&gt; + ":8443/" + getTicket(),
                            srcType: "FULL_PATH",
                            height: "800",
                            width:  "100%"
                         }
                     }
                ]
            }
        }]
};&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 08:52:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133766#M36018</guid>
      <dc:creator>AJ_</dc:creator>
      <dc:date>2021-06-07T08:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a URL from the browser in Share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133767#M36019</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/85993"&gt;@AJ_&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you looked at this &lt;A title="opens in a new window" href="https://stackoverflow.com/questions/13491604/how-to-retrieve-the-hostname-from-an-alfresco-share-webscript" target="_blank" rel="noopener nofollow noreferrer"&gt;approach&lt;/A&gt;?&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 10:34:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133767#M36019</guid>
      <dc:creator>EddieMay</dc:creator>
      <dc:date>2021-06-07T10:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a URL from the browser in Share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133768#M36020</link>
      <description>&lt;P&gt;Hi Eddie,&lt;BR /&gt;I did and although I agree that writing something like this might help me with solving this, it seems to me like killing a mosquito with a bazooka &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;.&lt;BR /&gt;Considering how simple it is to get the hostname with javascript when it runs in the browser context, it's hard for me to believe that there is no API in the Share tier that could do the same for me.&lt;BR /&gt;Isn't there a way (API) how I can talk for example from page context (or other part of the Share) to the browser?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 09:11:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133768#M36020</guid>
      <dc:creator>AJ_</dc:creator>
      <dc:date>2021-06-14T09:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a URL from the browser in Share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133769#M36021</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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. &lt;A href="https://github.com/Alfresco/share/blob/ee2b96a08a0b419661317b38400a4b5ecc7e5346/packaging/distribution/src/main/resources/web-extension-samples/share-config-custom.xml#L215" target="_self" rel="nofollow noopener noreferrer"&gt;repository-url for Share to create WebDAV links&lt;/A&gt;) and can be retrieved in server-side JS code &lt;A href="https://github.com/Alfresco/share/blob/ee2b96a08a0b419661317b38400a4b5ecc7e5346/share/src/main/resources/alfresco/site-webscripts/org/alfresco/share/imports/document-library.lib.js#L473" target="_self" rel="nofollow noopener noreferrer"&gt;like this&lt;/A&gt;. 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 &amp;lt;config&amp;gt; element which is the entrypoint to a so called "config section".&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 10:40:48 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/getting-a-url-from-the-browser-in-share/m-p/133769#M36021</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2021-06-14T10:40:48Z</dc:date>
    </item>
  </channel>
</rss>

