I can't figure out how to make an authentication middleware for my API please help

I'm using credentials provider with jwt from nextauth and then I have a middleware.ts in the root folder with just this content
export { default } from "next-auth/middleware"

export const config = {
matcher: ['/api/user/getuser'],
};
export { default } from "next-auth/middleware"

export const config = {
matcher: ['/api/user/getuser'],
};
which works if I pass static pages on the matcher but It doesn't work for the api. I've also tried to make a wrapper middleware returning an async function inside sort of but I get something like resolver is not defined so how can I make just a simple middleware that checks if the user is logged in on the backend? I've tried lots of tutorials and read the docs too and I can't make it work. 😦 Can I get some help or at least get pointed in the right direction?
2 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Fervore
Fervore•2y ago
I think that'll do it tnak you very much
Want results from more Discord servers?
Add your server