我在我的开发环境中使用 grunt connect 和 livereload。
我希望能够调用 /server 下的生产 api。
为此,我需要直接从
http://localhost:9000/server
到
http://www.production-server.com/server
这对我有好处,因为有时我想在开发模式下对生产服务器进行测试。
这是我当前的连接配置(由 Yeoman 生成):
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},
livereload: {
options: {
open: true,
middleware: function(connect, options, middlewares) {
return [
connect.static('.tmp'),
connect().use(
'/bower_components',
connect.static('./bower_components')
),
connect.static(appConfig.app)
];
}
}
},
test: {
options: {
port: 9001,
middleware: function(connect) {
return [
connect.static('.tmp'),
connect.static('test'),
connect().use(
'/bower_components',
connect.static('./bower_components')
),
connect.static(appConfig.app)
];
}
}
},
dist: {
options: {
open: true,
base: '<%= yeoman.dist %>'
}
}
},