Flex Remoting to CFCs under a Fusebox 5.5.1 Application.cfc

I recently started using Fusebox again and one issue I ran into was that Flex Remoting calls to CFCs under my Fusebox application were not working. (The application in question used an extended version of Fusebox's Application.cfc.) To work around the issue I put the remote components under a different, minimal, Application.cfc which used the same name as my main applicaiton. Something like the following:

<cfcomponent>
<cfset this.name="myApp" />
</cfcomponent>

This fixed the issue, but I was still a little puzzled. It is well know that the Application.cfc onRequest method doesn't play well with Flex Remoting, but I looked at Fusebox's Application.cfc and thought it was handling the issue with the following code in onRequestStart:

<!--- ensure CFC / Web Service / Flex Remoting calls are not intercepted --->
<cfif right(arguments.targetPage,4) is ".cfc">
<cfset doCompile = false />
<cfset structDelete(variables,"onRequest") />
<cfset structDelete(this,"onRequest") />
<cfreturn/>
</cfif>

Well, today I had a little bit of time to look into this and it turns out that for Flex Remoting requests the targetPage is "/flex2gateway," not the name of the target CFC. It was a bit of a "duh" moment, because if you have ever looked at a services-config.xml file or watched Flex Remoting requests via a proxy like ServiceCapture then you know the URL used is something like http://localhost/flex2gateway. Anyway, to fix the issue I ended up modifing the Fusebox Application CFC code above to the following:

<cfif right(arguments.targetPage,4) is ".cfc" or findNoCase("/flex2gateway",arguments.targetPage) gt 0>
<cfset doCompile = false />
<cfset structDelete(variables,"onRequest") />
<cfset structDelete(this,"onRequest") />
<cfreturn/>
</cfif>

Now I no longer need to remember to add a custom Application.cfc for remote CFCs.

It is important to note that Flash Remoting can be configured to use any URL, but this at least covers the default configuration for ColdFusion.

Comments
John Whish's Gravatar Hi Nathan, have you added a ticket for this? I couldn't see it on http://trac.fuseboxframework.org/fusebox/report/1?...
# Posted By John Whish | 3/12/09 12:37 PM
Nathan Mische's Gravatar Hi John, I didn't add a ticket, but I posted to the mailing list. Adam replied that this should be fixed (in one way or another) in the next release.
# Posted By Nathan Mische | 3/12/09 9:13 PM
Kyle's Gravatar I just wanted to say thank you for this solution. I had been beating my head against the wall for a day and a half over this. Seriously, I cannot thank you enough.
# Posted By Kyle | 11/6/09 3:21 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.