fix 404 mail error

pull/1/head
ClaraCrazy 2024-01-26 02:41:50 +01:00
parent 61019e649a
commit f9a26cd631
4 changed files with 12 additions and 30 deletions

View File

@ -1,21 +0,0 @@
const express = require('express')
const router = new express.Router()
const config = require('../../../application/config')
router.get(
'^/:404',
async (req, res) => {
res.render('error', {
title: "48hr.email | 404",
message: error.message,
status: 404,
address: req.params.address,
stack: error.stack,
madeby: config.branding[1],
madebysite: config.branding[2]
})
}
)
module.exports = router

View File

@ -44,7 +44,15 @@ router.get(
madebysite: config.branding[2]
})
} else {
res.redirect('/404')
res.render(
'error',
{
address: req.params.address,
message: 'This mail could not be found. It either does not exist or has been deleted from our servers!',
madeby: config.branding[1],
madebysite: config.branding[2],
}
)
}
} catch (error) {
console.error('error while fetching one email', error)

View File

@ -5,13 +5,10 @@
<a href="/inbox/{{ address }}">
← Return to inbox</a>
<br>
<a href="/inbox/{{ address }}/delete/{{ uid }}">
Delete Email</a>
<br>
<a href="/logout">
Logout</a>
</div>
<h1>{{message}}</h1>
<h2>{{status}}</h2>
<pre>{{stack}}</pre>
<h2>{{error.status}}</h2>
<pre>{{error.stack}}</pre>
{% endblock %}

View File

@ -11,7 +11,6 @@ const socketio = require('socket.io')
const config = require('../../application/config')
const inboxRouter = require('./routes/inbox')
const loginRouter = require('./routes/login')
const errorRouter = require('./routes/error')
const {sanitizeHtmlTwigFilter} = require('./views/twig-filters')
// Init express middleware
@ -50,7 +49,6 @@ app.get('/', (req, res, _next) => {
app.use('/', loginRouter)
app.use('/inbox', inboxRouter)
app.use('/404', errorRouter)
// Catch 404 and forward to error handler
app.use((req, res, next) => {