开发者

How to design single page application in javascript to work in environment mode?

开发者 https://www.devze.com 2022-12-22 19:00 出处:网络
I\'m developing single page application in javascript and consume data fr开发者_Go百科om RESTful web service. I host it on simple lighttpd web server. I want to have different url for consuming data b

I'm developing single page application in javascript and consume data fr开发者_Go百科om 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号