Grunt连接代理redirect?
我在前端安装了AngularJS,后端安装了Java Spring 3。
所以当我运行grunt-server时,我使用grunt-connect-proxy来联系后端部分forms的前端部分。
所以我的连接configuration是这样的:
connect: { proxies: [ { context:'/mdp-web', host: 'localhost', port: 8080, https: false, changeOrigin: true } ], options: { port: 9000, // Change this to '0.0.0.0' to access the server from outside. hostname: 'localhost' }, livereload: { options: { middleware: function (connect) { return [ proxySnippet, lrSnippet, mountFolder(connect, '.tmp'), mountFolder(connect, cegedimConfig.app) ]; } } } }
但我的问题是,在Java中,应用程序的上下文是mdp-web/
但在AngularJS中,我的uri就像: /api/users
$resource('/api/users', {}, { query: { isArray: true, method:'GET', cache: HttpCache } });
我想代理所有的/ api / uris,但redirect到/ mdp-web / api
是否有可能做到这一点与grunt连接代理(也许与重写属性)?
如果你有一个想法,我真的把它!
使用重写规则:
proxies: [ { context:'/api', host: 'localhost', port: 8080, https: false, changeOrigin: true, rewrite: { '^/api': '/mdp-web/api' } } ]