我正在尝试在我的Gruntfile中设置代理。这是我的Gruntfile.js:
module.exports = function(grunt) {
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
dirs: {
js: ['app/js/**/*.js', '!app/js/libs/**/*.js'],
html: ['app/index.html'],
},
connect:{
development: {
options: {
port: 9000,
middleware: function(connect) {
return [proxySnippet];
}
},
proxies: {
context: '/users',
host: '99.44.242.76',
port: 3000,
https: false
}
}
},
watch: {
options: {
livereload: true
},
html: {
files: ['<%= dirs.html %>']
},
js: {
files: '<%= dirs.js %>',
tasks: ['jshint']
}
}
});
grunt.registerTask('server', ['less', 'configureProxies', 'connect', 'watch']);
};在我添加了中间件之后,我得到了livereload Chrome扩展的404,然后我得到了index.html的404。

我做了什么错误的设置?
发布于 2013-11-16 20:44:42
在proxy文件中尝试此代码,并将此模式替换为proxy文件中的代理部件设置
grunt.initConfig({
connect: {
options: {
port: 9000,
hostname: 'localhost'
},
proxies: [
{
context: '/cortex',
host: '10.10.2.202',
port: 8080,
https: false,
changeOrigin: false,
xforward: false
}
]
}
})请阅读本期https://github.com/drewzboto/grunt-connect-proxy/issues/18
我认为你没有在选项中设置主机名。
https://stackoverflow.com/questions/20018514
复制相似问题