Use empty route to match global routes

This commit is contained in:
Dave Smith-Hayes 2024-03-03 22:25:48 -05:00
parent a36fff1e9d
commit ec7b95bbac
2 changed files with 4 additions and 3 deletions

View File

@ -5,7 +5,8 @@ import { LoginPage } from '../frontend/pages/login';
const LoginHandler = new Hono();
LoginHandler.get('/login', async (c: Context) => {
return c.html(<LoginPage />);
const errors = c.get('login-errors');
return c.html(<LoginPage error={errors} />);
});
LoginHandler.post('/login', async (c: Context) => {
@ -21,7 +22,7 @@ LoginHandler.post('/login', async (c: Context) => {
}
}
c.set('login-errors', {});
c.set('login-errors', { error: { message: "Bad credentials" }});
return c.redirect('/login');
});

View File

@ -12,6 +12,6 @@ app.get('/', async (c) => {
});
// Handlers
app.route('/*', LoginHandler);
app.route('', LoginHandler);
export default app;