Custom Server Port and GetLink

I was wondering if anyone else uses FarCry with a non standard port? If so, have you noticed the following behaviour:

If I use the code below for localhost:8008, link becomes http://localhost:8008:8008

<cfset link = application.fapi.getLink(alias="home", includeDomain="true") >

This may be a setup specific thing and only occurs for non standard ports. I am using Lucee 4.5 with IIS 7.5.

I often run it in Lucee express on port 8888, but I can’t say I have used/tested the includeDomain option.

It seems like some code might be using cgi.http_host plus the cgi.server_port when perhaps it should used cgi.http_host only (or cgi.server_name and cgi.server_port)? I’ll check when I get a chance :slight_smile:

Might not be as easy as that. As far as I am aware, there can be differences with server variables between IIS, Apache, etc.

The following may be sufficient:


<cfif not listfindnocase("80,443",CGI.SERVER_PORT)>
    <cfset arguments.Domain = "#arguments.domain#:#CGI.SERVER_PORT#" />


<cfif not listfindnocase("80,443",CGI.SERVER_PORT) and reFind(":\d+/?$", arguments.Domain) eq 0 >
    <cfset arguments.Domain = "#arguments.domain#:#CGI.SERVER_PORT#" />

Ie. if there’s already a port in the domain, don’t override it. Also means user provided domains can contain different custom ports

The logic definitely seems wrong to me, because this already includes the port (hence, so should any user provided value if it’s required);

<cfargument name="Domain" default="#cgi.http_host#">

Which means the code that follows shouldn’t be trying to append the port when it’s already expected to be there?

So perhaps the “fix” is to delete these 3 lines of code:

<cfif not listfindnocase("80,443",CGI.SERVER_PORT)>
	<cfset arguments.Domain = "#arguments.domain#:#CGI.SERVER_PORT#" />

Does that work for you?

@mrfelna I saw that you replied by email but it looks like the forum isn’t picking up email replies at the moment, I’m just trying to resolve it…

Should it be using getCanonicalDomain instead?


Yes - that makes sense. Embarrassingly simple.

Are you sure HTTP_HOST will always be:

a) defined
b) have a custom port appended

Just a thought. I think too much has already gone into a bug no one else
will care about :smile:

Test, please ignore…