[ColdBox-4.3] event.buildLink() returning IP instead of URL with server name

137 views
Skip to first unread message

Angel Chrystian Torres Guzman

unread,
Feb 1, 2018, 9:33:27 AM2/1/18
to ColdBox Platform
Hi,

In my handler I define a variable in the PRC as an exit handler to use for action in my Login Form
prc.exHandler = event.buildLink( 'security.Home.doLogin' );

The expected value is something like this
 https://mydomain.org/security/Home/doLogin

By get this

 https://74.127.59.243/security/Home/doLogin

So when the form is submitted and as I am using SSL the connection is seen as it comes from an "untrusted" domain. Only when I restart the framework it starts working as expected.


Why this could be happening?.

Thanks.

Angel

Pascal Peters

unread,
Feb 1, 2018, 10:08:26 AM2/1/18
to ColdBox Platform
The domain is retrieved from the SESBaseURL, which is set in the Routes.cfm.
If you took the standard Routes.cfm it has a line

setBaseURL("http://#cgi.HTTP_HOST#");

This means the domain will be set to the HTTP_HOST of your first request to the application (which was probably 74.127.59.243).
To avoid this, you can either hardcode the BaseURL in the Routes.cfm or use the baseURL argument in buildlink()

Pascal


Op donderdag 1 februari 2018 15:33:27 UTC+1 schreef Angel Chrystian Torres Guzman:

Angel Chrystian Torres Guzman

unread,
Feb 1, 2018, 11:11:40 AM2/1/18
to ColdBox Platform
Pascal, thanks for your response.

Yes I use the standard Routes.cfm the problem in harcoding that is that it varies according to the environment i.e.
http://dev.mydomain.org, https://staging.mydomain.org, https://mydomain.org, the same case for using the  BaseURL argument in buildLink

Maybe I will need to check the IP to see if I'm on production, but the think is that staging is the same IP, I'm just using a subdomain.
What would be the difference if I use CGI.SERVER_NAME instead?

Thanks.

Pascal Peters

unread,
Feb 8, 2018, 3:48:10 AM2/8/18
to ColdBox Platform
This is actually fixed in ColdBox 5.0 where the SESBaseUrl supports multiple domains. It doesn't cache the value anymore, but gets it from the CGI.HTTP_HOST on each request.

The way we fixed this before was using a requestContextDecorator to fix the buildlink method.


Op donderdag 1 februari 2018 15:33:27 UTC+1 schreef Angel Chrystian Torres Guzman:
Hi,

Brad Wood

unread,
Feb 8, 2018, 1:04:19 PM2/8/18
to ColdBox Platform
You just need to install the ses-on-request module.  It uses whatever host is in the URL for the base URL.  Alternatively, if you only ever want your app to use a single host for all URLs, just hard code it in routes.cfm and stop using cgi.http_host, which will just pick up whatever host is being used at the time the framework reinits.

Thanks!

~Brad

Angel Chrystian Torres Guzman

unread,
Feb 8, 2018, 9:10:47 PM2/8/18
to col...@googlegroups.com

Ok, I will install the ses-on-request module.

 

Thanks Pascal and Brad

 

Angel

https://lh3.googleusercontent.com/-mrtDByr7too/WnMlDVUdJFI/AAAAAAAAK78/ibpQ6FJ4XAIq8bFQVVgH-3YpMgGw9_q9QCLcBGAs/s1600/ssl_error.PNG

 

Why this could be happening?.

 

Thanks.

 

Angel

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to a topic in the Google Groups "ColdBox Platform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/coldbox/zQ6uuqcsIsY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/4896ba4a-cea6-4797-8f47-bd6e1c6a37a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Reply all
Reply to author
Forward
0 new messages