Skip to content
Discussion options

You must be logged in to vote

Hi people,
I have a situation where I created an authorization middleware for my API. The situation is that I use the middleware with nextConnect and then I do:

const handler = nextConnect();

handler.use(databaseMiddleware);

handler.get(.........);
handler.post(.......);

export default handler

I want to use my authorization middleware just for the post route and not for the get. But if I do handler.use() it will be used by both, is there a way to do that?

Hi! What about this?

handler.post('/', databaseMiddleware);

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@matheusrocha89
Comment options

@matheusrocha89
Comment options

@musme
Comment options

@matheusrocha89
Comment options

@matheusrocha89
Comment options

Answer selected by matheusrocha89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants