java - What are some techniques for deploying a single page application that depends on a rest api? -
i'm building single page application (using angularjs) renders data rest api call makes legacy system. legacy system large, written in java , takes minutes deploy decided more productive develop single page application separate legacy system.
the problems occurred once tried communicate legacy system's rest api. although both apps deployed locally same host, deployed on different app servers needed use different ports when communicating. because spa communicating rest api on different port, browsers prevented requests protect against cross site scripting attacks.
we found build tool name lineman (that leverages grunt) made easy proxy http requests. got around cross site scripting limitation suitable in development mode.
now we've got proof of concept working, want know how we're supposed deploy these apps without proxying. it's hard me find advice on how because angular doesn't assume have backend in first place , people use angular on front end aren't using java in backend (if matters).
we're running issues like, context paths of apps change depending on if they're deployed in prod mode vs dev mode we've gotta think of clever ways avoid broken links work both modes. wonder if/where took wrong step here along way. should avoid developing spa on separate server backend?
we had same issues. url situation have different url paths java rest api because in different environments.
in order make these paths cascade down angular application, had first externalize base paths in web app (the app spawns angular) use values set during deployment depending on deployed to. have values in our app servers link xml values in config files reference in application.
then create call angular app webapp spawns (not java rest api) return url correct environment.
in angular application, can setup resuorce correct base path (the rest of url should stay same environment environment).
if can first part working correctly externalizing environmental settings, rest not difficult.
Comments
Post a Comment