angularjs - http-rewrite-middleware with generator-cg-angular -


anyone succeded use "http-rewrite-middleware" "generator-cg-angular"??

i try setup in gruntfile.js, similar recomend grunt connect.

var rewritemodule = require('http-rewrite-middleware'); 

and in grunt.initconfig have

connect: {   main: {     options: {       port: 9001,       hostname: 'localhost'     },   },   development: {       options: {           middleware: function (connect, options) {               var middlewares = [];                // rewriterules support               middlewares.push(rewritemodule.getmiddleware([                   {from: '^/rest/user', to: '/json/user.json'}               ]));                if (!array.isarray(options.base)) {                   options.base = [options.base];               }                var directory = options.directory || options.base[options.base.length - 1];               options.base.foreach(function (base) {                   // serve static files.                   middlewares.push(connect.static(base));               });                // make directory browse-able.               middlewares.push(connect.directory(directory));                return middlewares;           }       }   } } 

then output running "grunt serve"

running "connect:main" (connect) task started connect web server on http://localhost:9001 running "connect:development" (connect) task rewrite rule created for: [rewrite: ^/rest/user -> /json/user.json]. started connect web server on http://localhost:8000 

but when $http.get('rest/user') give me output

"networkerror: 404 not found - http://localhost:9001/rest/user" 

but if change port 8000, work.

i have earlier used "grunt-connect-rewrite" , there worked out of box more or less, never had issue port 8000, there asks on port asked no problems.

what need configure make work in cg-angular without having add port 8000 on requests?

solution "http-rewrite-middleware" "generator-cg-angular" in gruntfile.js:

connect: {   main: {     options: {       port: 9000,       hostname: 'localhost',       base: '',       middleware: function (connect, options) {               var middlewares = [];                // rewriterules support               middlewares.push(rewritemodule.getmiddleware([                   {from: '^/rest/user', to: '/json/me.json'}               ]));                if (!array.isarray(options.base)) {                   options.base = [options.base];               }                var directory = options.directory || options.base[options.base.length - 1];               options.base.foreach(function (base) {                   // serve static files.                   middlewares.push(connect.static(base));               });                // make directory browse-able.               middlewares.push(connect.directory(directory));                return middlewares;           }     },   } } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -