Forum Moderators: phranque

Message Too Old, No Replies

ProxyPass and XHR - PHP works but JS does not

         

markwhite

10:33 am on Sep 12, 2009 (gmt 0)

10+ Year Member



I'm working on a front end that calls REST APIs provided by the client and have run up against the cross-domain problems with XHR. And now I'm getting into territory that is very new to me so please excuse any incorrect terminology.

The front end uses PHP for some XHR and JavaScript for other AJAX calls to avoid screen refreshes. And initial cross-domain probelms were solved on a local test server (Win32 Apache 2.2.10) by the addition of the following to httpd.conf:

ProxyPass /58080/ [[url...] removed]:58080/fon11/
ProxyPassReverse /58080/ [[url...] removed]:58080/fon11/

XHR calls from both PHP and JS work fine.

A sandbox server (Fedora, Apache 2.2.6) has been provided to pre-live test the code, and I'm having problems. And I've amended httpd.conf as before, appreciating that more security will probably required after I've got it working.

After tracing down an initial problem to selinux and httpd_can_network_connect, PHP API calls now work perfectly. But Javascript still acts as if the proxy wasn't working - XHRs cycle thorugh statechange 1 and 2, jump stage 3 and exit at 4 with a status of 0. It seems that the ProxyPass is correctly formed, so I cannot understand why JS is still failing.

I have spent far too long getting nowhere on this and need a bit of expert advice. I'm not even sure that ModRewrite might not be a better option as the site will need to use HTTPS when live. Any advice would be much appreciated.

TIA,

Mark...

markwhite

12:56 pm on Sep 12, 2009 (gmt 0)

10+ Year Member



<smacks head on desk>

JS is client side, so references to "http://localhost/58080" were not the same as PHP references to "http://localhost/58080"

Resolved.

jdMorgan

5:38 pm on Sep 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good, because it's likely that a majority of contributors to this forum wouldn't know what REST or XHR are, without some generalization... No-one here knows *everything* about *anything* that could possibly be plugged into Apache. :)

And you'd be appalled at the number of "Webmasters" who don't know their server-side from their client-side, or who would say that your "Java" is client-side, thinking it the same as JavaScript...

Everybody gets one good "D'oh" per day in this forum... That was yours just now... ;)

Glad you got it figured out,
Jim