Auth.js and custom middleware
Unanswered
Tomistoma posted this in #help-forum
TomistomaOP
Hi, im having trouble using auth.js and a middleware for refreshing an api key. For example if in my middleware.ts I export " NextAuth(authConfig).auth "as default all the login auth works great but my API refresh doesnt work and if i export my middleware function as default API refresh works but my auth is broken. Is there any way I can use both functions as middlewares?
2 Replies
TomistomaOP
Im using Auth.js v5 and Next.js 14
middleware.ts
Auth middleware
API refresh middleware
Auth middleware
export default NextAuth(authConfig).auth; API refresh middleware
const middleware = async (request: NextRequest) => {
//refresh logic
}
export { middleware };