gpt4 book ai didi

javascript - 在nodejs和express中添加子域

转载 作者:搜寻专家 更新时间:2023-10-31 23:55:46 25 4
gpt4 key购买 nike

我正在尝试使用 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);
});

我这里有什么地方做错了吗?

最佳答案

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

manager.get('/', function (req, res) {
res.render('layout', {
title: 'Manager '
});
});

关于javascript - 在nodejs和express中添加子域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13434465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com