I'm currently developing an HTML5-JavaScript mobile app using PhoneGap and need to interact with a REST service.
The REST service is hosted at
"http://localhost:8080/backend/mvc/"
My development environment consists of a WAMP server (Apache2) at http://localhost/stage/
and I am using Chrome as my browser.
When attempting to make an AJAX call, the browser returns the error message:
XMLHttpRequest cannot load http://localhost:8080/backend/mvc/event. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
I have explored various solutions to bypass this cross-domain AJAX call issue:
1) Tried launching Chrome with the command line option
chrome.exe --disable-web-security
but it made no difference.
2) Attempted configuring Apache using mod_proxy to redirect the traffic.
In the httpd.conf file, I enabled the following modules:
proxy_module
proxy_connect_module
proxy_http_module
Additionally, I created a .htaccess
file in the root directory with the following rules:
# Enable mod_rewrite
RewriteEngine On
ProxyRequests off
<Proxy>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /EMBackend/ http://localhost:8080/backend/mvc/
ProxyPassReverse /EMBackend/ http://localhost:8080/backend/mvc/
RewriteRule ^/EMBackend/(.*)$ /backend/mvc/$1 [R]
After restarting all services (Apache, PHP, etc.), I encountered a 500 error.
The Apache error log reported:
[Tue Oct 18 14:30:11 2011] [alert] [client 127.0.0.1] C:/wamp/www/.htaccess: ProxyRequests not allowed here
Could anyone suggest a resolution for this issue?