OK, so I wanted to publish a solution that worked well for my local development, and allowed me to use the desired approach ... do it as Dook said (sorry, I'm not sure how to associate his username) and have two separate assemblies / projects. However, my external project uses grunt to serve my code on a specific port, with some middleware that sends requests to the port either to the front-end code or to the server running spring-boot. This allows me to act as if the code really works in one project and does not allow CORS and other problems to run them on different domains / servers. here is the code section in my grunt assembly that allows me to do this:
livereload: { options: { debug: true, middleware: function (connect, options) { var middlewares = []; middlewares.push(rewriteModule.getMiddleware([ //Load App under context-root of 'myappcontext/secured' {from: '^/napiweb/(.*)$', to: '/$1'}, //Redirect slash to myappcontext/secured as convenience {from: '^/$', to: '/napiweb', redirect: 'permanent'} //Send a 404 for anything else //{from: '^/.+$', to: '/404'} ])); if (!Array.isArray(options.base)) { options.base = [options.base]; } options.base.forEach(function () { // Serve static files. middlewares.push(connect.static('.tmp'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app)); }); // Make directory browse-able. //middlewares.push(connect.directory(directory)); return middlewares; } } },
Then I configured my spring-boot to have a proxy server for local development, which redirects certain requests to the interface. It is configured as follows: in the config.xml file
<config proxy-port="{{http-port}}" console-port="1776"> <console-recording sso="true" rest="true" max-entries="100" enable-debug- logging='true'/> <sso-cookie name="wamulator" domain=".somedomain.com" session-timeout-seconds="1800"/> <port-access local-traffic-only="false"/> <sso-traffic strip-empty-headers="true"> <by-site host="localhost.somedomain.com" port="{{http-port}}"> <cctx-mapping thost="127.0.0.1" tport="8081"> <policy-source>xml={{policy-src-xml}}</policy-source> </cctx-mapping> <cctx-mapping thost="127.0.0.1" tport="9000"> <policy-source>xml={{static-src-xml}}</policy-source> </cctx-mapping> <cctx-mapping thost="127.0.0.1" tport="8180"> <policy-source>xml={{napi-src-xml}}</policy-source> </cctx-mapping> </by-site> </sso-traffic> <user-source type='xml'>xml={{usr-src-xml}}</user-source> <proxy-timeout inboundMillis="0" outboundMillis="0" /> </config>
As you can see, the cctx mapping will direct some request to the front end, served on port 9000, and some to the backend serving the API. This is based on the policy-config.xml file and the static-config.xml files. They are almost exactly the same, and the only difference is setting authHost and cctx here for an example:
<deployment at='2013-01-31_16:25:12.205-0700'> <environment id='dev' host='dev.somedomain.com (exposee)'/> <application id='napi-rest' authHost='localhost.somedomain.com/napiweb/api' cctx='/napiweb/api'> <authentication scheme='anonymous' name='Anonymous Authentication'> </authentication> <authorization failure-redirect-url='/denied.html'> <default format='exposee' value='Allow Authenticated Users'> <headers> <success> ...profile-att specific for my organization </success> <failure> <redirect value='/denied.html'/> </failure> </headers> </default> <rule name='Allow Authenticated Users' enabled='true' allow-takes-precedence='false'> <allow> <condition type='role' value='Anyone'/> </allow> </rule> </authorization>
The only difference is that the other file has authHost='localhost.somedomain.com/napiweb/' cctx='/napiweb/' . This calls the API calls and the external interface, which will be called as if they were sent from the same project. Then, when we push projects to our repositories, we have two build cycles. One takes the front end and creates static assets using grunt build , and then copies these files to the rest of the server so that it can serve them. This allows us to have separate projects for development, but one server serving our site. Not perfect ... since in the end I think we should have separate servers / instances for front and back, but since we were not allowed to do this, it allowed us to act as if we were doing it during development. I hope this helps someone.