connect-history-api-fallback vs app.get('*', [callback])

Viewed 46

When solving SPA 404 problem, nomally use connect-history-api-fallback. but I don't know advantages of using that middleware.

app.use('/api',apiRouter);
app.get('*', (req,res) => {
    res.sendFile(path.join(__dirname,'~~'))
})

It has same result. Right?

What is the advantage of using connect-history-api-fallback?

I don't know the difference. And what kind of problems it causes.

0 Answers
Related