ColdBox is "forgetting" the routes

55 vistas
Ir al primer mensaje no leído

Now Culture

no leída,
31 may 2018, 10:43:22 a.m.31/5/18
para ColdBox Platform
I have an issue where if I don't use the ColdBox application for a while, it seems to forget the routing. Here is the redirect code in the handler:

<cfset event.setValue("fromLogin", true) />
<cfset setNextEvent(event=redirectPage, persist="fromLogin") />

The problem I had was that the page is https: but the setNextEvent drops the https: 

I fixed this in Routes.cfm, which looks like this:

<cfscript>
// Allow unique URL or combination of URLs, we recommend both enabled
setUniqueURLS(false);
// Auto reload configuration, true in dev makes sense to reload the routes on every request
//setAutoReload(false);
// Sets automatic route extension detection and places the extension in the rc.format variable
// setExtensionDetection(true);
// The valid extensions this interceptor will detect
// setValidExtensions('xml,json,jsont,rss,html,htm');
// If enabled, the interceptor will throw a 406 exception that an invalid format was detected or just ignore it
// setThrowOnInvalidExtension(true);
// Base URL
if( cgi.HTTPS is "off" ){
protocol = "http";
}
else{
protocol = "https";
}
if( len(getSetting('AppMapping') ) lte 1){
setBaseURL("#protocol#://#cgi.HTTP_HOST#/index.cfm");
}
else{
setBaseURL("#protocol#://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/index.cfm");
}
// Your Application Routes
addRoute(pattern=":handler/:action?");
</cfscript>

but as I said, if I leave the application for a while and come back to it, this no longer works and the https gets lost again. I have to do a fwreinit=1 to get it back.

Any ideas? Or any hints about forcing a fwreinit=1 when it's needed?


-Don

Brad Wood

no leída,
31 may 2018, 11:11:21 a.m.31/5/18
para col...@googlegroups.com
It sounds like your application is timing out, and some sort of HTTP-based call like a load balancer ping is reinitting the app. That base URL is cached for the life of the application and is set by whatever request first hits the framework when it comes up.  If you want it ot always be HTTPS then hard code it in that code.  Or if it needs to be different per tier, then set it as a setting in your ColdBox settings, and get it with getSetting() in your routing file.

Thanks!

~Brad

Developer Advocate
Ortus Solutions, Corp 

ColdBox Platform: http://www.coldbox.org 


--
--
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 the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+unsubscribe@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/0bdbf5cc-a2f0-43d7-b19c-172205e78975%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Now Culture

no leída,
31 may 2018, 12:22:34 p.m.31/5/18
para ColdBox Platform
There are lots of different settings in different places. Which setting do you mean?

Brad Wood

no leída,
31 may 2018, 12:27:34 p.m.31/5/18
para col...@googlegroups.com
I mean a setting of your own design.  You create it.  You set it to whatever you want for each environment using the environment overrides, and you use it in your routes config.

Thanks!

~Brad

Developer Advocate
Ortus Solutions, Corp 

ColdBox Platform: http://www.coldbox.org 


--
--
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 the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+unsubscribe@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.

Now Culture

no leída,
31 may 2018, 12:35:11 p.m.31/5/18
para ColdBox Platform
I tried doing it in config/ColdBox.cfc

I'll let you know how it goes!


On Thursday, May 31, 2018 at 10:43:22 AM UTC-4, Now Culture wrote:

Now Culture

no leída,
31 may 2018, 1:04:04 p.m.31/5/18
para ColdBox Platform
Something strange is happening. I added this to Coldbox.cfc

// Custom Settings
settings = {
protocol = "https:"
};


and then I coded Routes.cfm like this:

if( len(getSetting('AppMapping') ) lte 1){
setBaseURL("#getSetting('protocol')#://#cgi.HTTP_HOST#/index.cfm");
}
else{
setBaseURL("#getSetting('protocol')#://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/index.cfm");
}
// Your Application Routes
addRoute(pattern=":handler/:action?");


but now something recursive is happening. I guess AppMapping is getting the host added to it, but the only thing I did different was replace a local variable with getSetting

this is the url that is coming back when I do setNextEvent:





On Thursday, May 31, 2018 at 10:43:22 AM UTC-4, Now Culture wrote:

David Kreimer

no leída,
15 jun 2018, 10:20:47 a.m.15/6/18
para ColdBox Platform
You probably already found this but you have your protocol set to https: with the : after it, then you supply :// after the getSetting call, so it's doubling up on ::s.

Fix: change your settings to settings = { protocol = "https" }

(without the : on the protocol)

Now Culture

no leída,
27 jun 2018, 1:21:31 p.m.27/6/18
para ColdBox Platform
Thanks, David! That seems to have been the issue. 

Brad Wood

no leída,
27 jun 2018, 2:43:37 p.m.27/6/18
para col...@googlegroups.com
If the base URL changes after a while it's likely because your application scope times out and the next hit to the server re initializes the application.  The routes.cfm file is only run once when the app comes up and then it caches the setting.  If the first hit to your app is an HTTP hit (think a load balancer probe or something) then it will cache http for all URLs.

If you want all URLs to be built with HTTPS all the time, then simply remove that if statement based on the cgi scope and just hard code it to https.
 
Thanks!

~Brad

Developer Advocate
Ortus Solutions, Corp 

ColdBox Platform: http://www.coldbox.org 


--
--
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 the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.

To post to this group, send email to col...@googlegroups.com.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos