express.static正在處理根url請求。 例如我想做一個快速從https://example.com到https://example.com/dashboard的重定向。 檢查下面的情況,第一個工作,第二個不工作。我希望第二個也能工作。有人知道爲什麼express.static處理根url請求
案例1(作品)
app.get('/', (req, res, next) => {
res.redirect('/dashboard');
})
app.use(express.static(path.join(__dirname, 'dist')))
app.get('/dashboard', (req, res, next) => {
//do stuff
})
案例2(不爲我工作)
app.use(express.static(path.join(__dirname, 'dist')))
//request doesn't come here
app.get('/', (req, res, next) => {
res.redirect('/dashboard')
})
app.get('/dashboard', (req, res, next) => {
//do some stuff
})
改變DIST到/ DIST應該使其工作 – itsundefined