Closed gyto closed 1 year ago
It can. This is what the new edgeRouter
is for: https://github.com/hoangvvo/next-connect#nextjs-edge-api-routes-beta. But instead of calling .handler()
, you can call .run(). Will put together a quick example.
I added an example to README: https://github.com/hoangvvo/next-connect#nextjs-middleware
Thanks @hoangvvo, I'll play around when I needed :)
As of nextjs v12.2.0 release, Vercel introduces a
stable
version of middleware.I was wondering can next-connect be used in middleware itself. I did not try it yet, but it would be great to see some examples. Currently I have
getServerSideProps
extend next-connect authentication for every server-side pages. and it nightmare to control them because I already have 20+ pages for them. So I decided to switch to middleware to just match a single route and make everything in one spot.I will test it later tonight and post my example here.