mirror of
https://github.com/Crazyco-xyz/48hr.email.git
synced 2025-12-14 05:46:33 +01:00
fix trailing slash errors
This commit is contained in:
parent
fbe45c6804
commit
31e7594b2f
1 changed files with 11 additions and 1 deletions
|
|
@ -25,7 +25,17 @@ app.set('socketio', io)
|
|||
app.use(logger('dev'))
|
||||
app.use(express.json())
|
||||
app.use(express.urlencoded({ extended: false }))
|
||||
// View engine setup
|
||||
|
||||
// Remove trailing slash middleware (except for root)
|
||||
app.use((req, res, next) => {
|
||||
if (req.path.length > 1 && req.path.endsWith('/')) {
|
||||
const query = req.url.slice(req.path.length) // preserve query string
|
||||
return res.redirect(301, req.path.slice(0, -1) + query)
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
// View engine setup
|
||||
app.set('views', path.join(__dirname, 'views'))
|
||||
app.set('view engine', 'twig')
|
||||
app.set('twig options', {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue