views:

35

answers:

1

I'm developing single page application in javascript and consume data from RESTful web service. I host it on simple lighttpd web server. I want to have different url for consuming data by environment like development mode points to my local web service and production mode point to online webservice.

A: 

Route all XMLHttpRequest through a wrapper. In this wrapper, initialize the environment that basically sets the base URL for all outgoing requests. Since you're using a RESTful design, I suppose the URIs are going to be the same for each environment, only the base path is going to change.

Anurag