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 (나를 위해 작동하지 않습니다) 파일 dist/index.html
가 있다면 그 검색 할 때 찾는 것이 무엇 express.static()
때문에, 일어날 것
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
})
그것이 – itsundefined