0
问题是静态文件(CSS,JS)唯一的工作中的一条路径,但不是others.For模板我使用的把手,这里是我的代码片段:快速静态文件只在一个路由工作
var express = require('express'),
........
exphbs = require('express-handlebars');
auth = require('./routes/auth')(Account);
.........
app.use(express.static(__dirname + '/public'));
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');
app.use('/auth', auth); //static files not working
app.get('/', function(req, res) { // static files working
res.render('index');
});
对于/auth
路线,我得到404状态
您是否尝试过使用权威性的绝对路径固定我的问题? auth = require('/ installdir/abc/routes/auth')(Account); –
你应该在'/'和'/ auth'下显示你使用的页面模板,这样我们就可以看到你如何引用你的静态资产。 – mscdex
是你的模板中的静态资产的绝对或相对的网址?他们应该是绝对的。 – Sgnl