H
Hono•7mo ago
Tempo

Having middleware routes in RPC

Hi, I'm setting up honojs as the API of a SPA, with authjs as authentication library using the honojs middleware (https://github.com/honojs/middleware/tree/main/packages/auth-js) I have the auth and RPC setup in the following way
app.use('/auth/*', authHandler());
app.use('*', verifyAuth());

const routes = app.route('/users', users);
export type AppType = typeof routes;
app.use('/auth/*', authHandler());
app.use('*', verifyAuth());

const routes = app.route('/users', users);
export type AppType = typeof routes;
but I wish I could get the auth endpoints (created by the authHandler) in the RPC aswell. Is it possible ?
3 Replies
Artifex
Artifex•7mo ago
chain them in const routes
const routes = app.use('/auth/*', authHandler()).use('*', verifyAuth()).route('/users', users);
export type AppType = typeof routes;
const routes = app.use('/auth/*', authHandler()).use('*', verifyAuth()).route('/users', users);
export type AppType = typeof routes;
Tempo
TempoOP•7mo ago
It doesn't seem to work 😦
No description
No description
Artifex
Artifex•6mo ago
what does your actual /auth look like
Want results from more Discord servers?
Add your server