Purpose
I was wanting to keep my front end project separate from my backend. This meant that the back end was on a different port than the yeoman server. This causes cross site scripting issues with the yeoman server. I figured out the only way around this was via a proxy.
I found this article from Mike Partridge from Jan 2014 which was a good starting point but the yeoman build has changed so this is no longer working.
http://www.hierax.org/2014/01/grunt-proxy-setup-for-yeoman.html
Tools used
-
grunt-cli v0.1.13
-
grunt v0.4.5
-
yeoman 1.2.0
-
grunt-connect-proxy 0.1.10
- angular-generator 0.9.1
Change to instructions
The only change to the directions in the post from hierax is the following. I just changed the things that are pushed into middleware. Live reload no longer has a base [ ] block.
Step 3 should now look like:
livereload: { options: { open: true, middleware: function (connect) { // Setup the proxy var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest]; middlewares.push(connect.static('.tmp')); middlewares.push(connect().use( '/bower_components', connect.static('./bower_components') )); middlewares.push(connect.static(appConfig.app)); return middlewares; } } },