3

我正在尝试使用 node.sj 和 Expressjs v3 添加子域,但在尝试加载子域时我不断收到 404 cannot get / 。

var express = require('express'),
    app = module.exports = express(),
    MongoStore = require('connect-mongodb'),
    server = require('http').createServer(app),
    fs = require('fs'),
    socket = require('./lib/sockets'),
    flash = require('./middleware/flash');

app.configure('development', function () {
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
});

app.configure('production', function () {
    app.use(express.errorHandler()); 
});

app.configure(function () {
    app.use(express.favicon(__dirname + '/public/domain.com/images/favicon.ico'));
    app.engine('.html', require('ejs').__express);
    app.set('views', __dirname + '/views/site');
    app.set('view engine', 'ejs');
    app.use(express.cookieParser());
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(flash());
    app.use(app.router);
    app.use(express.vhost(app.get('manager_vhost'), require('./subdomains/Manager')));

});

server.listen(3000);
socket.listen(server, sessionStore, app);

这就是我的经理文件中的内容

var express = require('express'),
    manager = module.exports = express();


manager.configure(function () {
    manager.use(express.static(manager.get('base_location') + '/public/'));
    manager.engine('.html', require('ejs').__express);
    manager.set('view engine', 'ejs');
    manager.set('version', version);
});

我在这里做错了什么吗?

4

1 回答 1

2

您的路线在哪里定义?尝试添加路线,看看会发生什么

manager.get('/', function (req, res) {
    res.render('layout', { 
        title: 'Manager '
    });
});
于 2012-11-17T20:27:04.413 回答