회원가입 기능은 axios.post('/sign-up', 으로 해서 mongodb저장되는 것까지 완료되었는데, 로그인 기능이 막혀서 질문드립니다.
node 마지막 강의처럼 아래와 같이 해놓았는데요.
app.get('/', (req,res) => {
res.sendFile(__dirname + '/code-vue/dist/index.html')
});
app.get('*', (req,res) => {
res.sendFile(__dirname + '/code-vue/dist/index.html')
});
어떤 페이지든 로그인을 해야 들어갈 수 있도록 '로그인했니'를 미들웨어로 집어 넣게 되면, 아래와 같이 되는 데요.
app.get('/', 로그인했니, (req,res) => {
res.sendFile(__dirname + '/code-vue/dist/index.html')
});
app.get('*', 로그인했니, (req,res) => {
res.sendFile(__dirname + '/code-vue/dist/index.html')
});
function 로그인했니(req,res, next) {
if (req.user) {
next()
} else {
res.redirect('/')
}
}
*에 대해 index.html파일을 주도록 되어 있어서 그런건지 다른페이지로 routing이 안됩니다ㅠㅠ
vue + express로 했을 때 로그인 기능을 전체적으로 어떤 흐름으로 만들어주어야 할까요? 전혀 감을 못잡겠네요. 이것만 일주일동안 고민하고 있습니다. ㅠㅠ