why-no-worky

pull/1/head
ClaraCrazy 2024-01-26 02:10:58 +01:00
parent 3c69fb5761
commit 61019e649a
4 changed files with 35 additions and 7 deletions

View File

@ -0,0 +1,21 @@
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,10 +44,7 @@ router.get(
madebysite: config.branding[2] madebysite: config.branding[2]
}) })
} else { } else {
next({ res.redirect('/404')
message: 'This mail could not be found. It either does not exist or has been deleted from our servers!',
status: 404
})
} }
} catch (error) { } catch (error) {
console.error('error while fetching one email', error) console.error('error while fetching one email', error)

View File

@ -1,9 +1,17 @@
{% extends 'layout.twig' %} {% extends 'layout.twig' %}
{% block body %} {% block body %}
<div style="float: right"><a href="/logout"> Logout</a></div> <div style="float: right; text-align: end;">
<a href="/inbox/{{ address }}">
← Return to inbox</a>
<br>
<a href="/inbox/{{ address }}/delete/{{ uid }}">
Delete Email</a>
<br>
<a href="/logout">
Logout</a>
<h1>{{message}}</h1> <h1>{{message}}</h1>
<h2>{{error.status}}</h2> <h2>{{status}}</h2>
<pre>{{error.stack}}</pre> <pre>{{stack}}</pre>
{% endblock %} {% endblock %}

View File

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