我的代码非常简单,grunt文件是,
module.exports = function(grunt) {
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
grunt.initConfig({
connect: {
server: {
options: {
hostname: "localhost",
keepalive: true,
base:['../web/'],
port: 8080,
middleware: function(connect, options) {
return [proxySnippet];
},
debug: true
}
}
}
});
// grunt.loadNpmTasks('grunt-connect-proxy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', [
'connect:server'
]);
};有一个index.html,路径是"../web/index.html“。当我打开的时候
"http://localhost:8080"它给出"Cannot GET /“。你知道为什么会发生这种事吗?
发布于 2015-02-19 20:29:31
对于如下所示的目录结构:
-node_modules
-templates
---index.html
---login.html
-Gruntfile.js
connect: {
options: {
port: 9000,
livereload: true,
hostname: 'localhost',
},
livereload: {
options: {
open: true,
base: ['templates/']
}
}
}这将在浏览器上打开模板的完整目录结构,以导航到任何html页面。
发布于 2015-02-19 21:36:56
删除中间件代理,如下所示:
module.exports = function(grunt) {
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
grunt.initConfig({
connect: {
server: {
options: {
hostname: "localhost",
keepalive: true,
base:['../web/'],
port: 8081,
debug: true
}
}
}
});
// grunt.loadNpmTasks('grunt-connect-proxy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', [
'connect:server'
]);
};而且必须工作。
https://stackoverflow.com/questions/27716569
复制相似问题