View Full Version : How to set the proxy URL

22 Aug 2011, 2:00 PM

How to set a proxy URL in ExtJS?

In Sproutcore, we have a Buildfile where we set -

proxy '/login' :to => 'localhost:4567'

In ExtJS, to post a JSON object, we use the following code:

method: 'POST',
headers: {'Content-Type':'application/json'},
jsonData:{"userName": value,
"password": value,
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('Status', '', obj);
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('', obj.errors.reason);
Ext.Msg.alert('','' +response.responseText);


Where should I set the URL -> http://localhost:4567 ??

The server is running @ localhost:4567. (I have to send JSON object to the url "http://localhost:4567/login" to get a response back.)

Thanks in advance.

23 Aug 2011, 11:58 AM
/login should be Fine.

You should be placing 'var ' in front of your obj reference declarations.

23 Aug 2011, 9:12 PM
@sagarsgiri: we've already discussed this on your other thread:


To reiterate what I explained there, you cannot use an alternative server for an Ajax request due to the same origin policy.

You'll need to handle the login request on the same webserver that serves up your page. This could simply forward the request on to your other server if that's what you want.