Direct .cfm template calls outside of Fusebox 5.5 when using Application.cfc

When attempting to run a non-fusebox .cfm template outside of Fusebox while using Application.cfc to extend the Fusebox Core files, Fusebox will re-route all requests through Fusebox regardless of what the template is called. This occurs because no fuseaction was specified and Fusebox, because was extended in Application.cfc, handles this as a Fusebox app call from the start.

The Scenario

For example in my webapp root I have Application.cfc which extends the Fusebox Core Files:

<cfcomponent extends="fusebox5.Application" output="false">

I also have in my webroot another template called cgi_dump.cfm which just contains <cfdump var=”#cgi#” />. When attempting to access cgi_dump.cfm in your browser directly (http://mysite.com/cgi_dump.cfm) your Fusebox App Core files will fire first, treating this as a missing fuse and will load the fusebox app default circuit.fuseaction.

Fix 1 - Keeping Application.cfc Fusebox extension

<cffunction name="onRequest">
<cfargument name="targetPage" type="string" required="true" />
<cfif ListLast(arguments.targetPage, "\/") eq myFusebox.getSelf()>
<cfset super.onRequest(arguments.targetPage) />
<cfelse>
<!--- Include the requested page. --->
<cfinclude template="#arguments.targetPage#" />
</cfif>
</cffunction>

This checks to see the name of the called template against the known fusebox ‘hub’ template (usually index.cfm). Just to make sure that myFusebox.getSelf() is set to "index.cfm" (which it won’t be if the fusebox app hasn’t been run before), then add the FUSEBOX_PARAMETER:

// force fusebox to only run if this script is called
FUSEBOX_PARAMETERS.self = "index.cfm";

You will also need to stop Fusebox debugging by adding the following onRequestEnd method to your Application.cfc.

<!--- not part of the Fusebox Application.cfc --->
<cffunction name="onRequestEnd">
<cfargument name="targetPage" type="string" required="true" />
<cfif ListLast(arguments.targetPage, "\/") eq myFusebox.getSelf()>
<!--- Pass request to Fusebox. --->
<cfset super.onRequestEnd(arguments.targetPage) />
</cfif>
</cffunction>

Fix 2 - Removing Application.cfc Fusebox extension

This is the simple fix. Just remove the Core File extension from Application.cfc

<cfcomponent output="false">

and include the Fusebox Core within your index.cfm as in previous versions and non Application.cfc Fusebox Applications:

<cfinclude template="/fusebox5/fusebox5.cfm" />

Additional Information

External Links