2015-08-08 53 views
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狀態

+0

您是否嘗試過使用權威性的絕對路徑固定我的問題? auth = require('/ installdir/abc/routes/auth')(Account); –

+1

你應該在'/'和'/ auth'下顯示你使用的頁面模板,這樣我們就可以看到你如何引用你的靜態資產。 – mscdex

+0

是你的模板中的靜態資產的絕對或相對的網址?他們應該是絕對的。 – Sgnl

回答