hoangvvo / next-connect

The TypeScript-ready, minimal router and middleware layer for Next.js, Micro, Vercel, or Node.js http/http2
https://www.npmjs.com/package/next-connect
MIT License
1.63k stars 65 forks source link

Hydrating the request #137

Open maganuk opened 3 years ago

maganuk commented 3 years ago

Hi,

I have an express middleware that has some api routes.

My middleware serves these pages if they match the glob. If it doesn't find a match it injects some user session data into the request object.

Is it possible to configure nextjs using next-connect in a way which will allow me to not handle a request but inject the data into it so that the same request can be handled by one of the pages?

Basically some sort of a middleware which runs before api and pages.

Thanks for any help

Vishal

hoangvvo commented 3 years ago

Yes, I think you are referring req.use (https://github.com/hoangvvo/next-connect#usebase-fn). If that is not what you meant, can you provide some code snippet to illustrate what you are trying to achieve? Thanks!