You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
If I understand correctly, so far the Express wrapper only targets API routes, not route handlers. This is a tad more complicated to setup because route handlers use a different structure for the request/response (the web platform ones, built-in node/browser and used by fetch) than Express.
Can you please confirm me that this is not possible in next-connect right now?
exportfunctionPOST(req: NextRequst){returnnespresso(// a normal Express middleware(req,res,next)=>{next()},(req,res,next)=>{res.send("foobar")})// returns Next Response}
Feel free to reuse this code if that sounds relevant to you. The typings are giving me a hard time (somehow "res.status" is not found, and "Handler" type is not accepted as a middleware) and features are missing but it roughly works otherwise.
After a few more experiments, I fail to properly create an Express response/request directly from Express codebase, this forces me to mimick all features but then writing the request seems to fail.
Setting relevant methods by hand, it mostly works however somehow passport can't set "res.user", I can't tell why, while it can set "_passport". I don't have a minimal repro yet.
The text was updated successfully, but these errors were encountered:
eric-burel
changed the title
Express wrapper + route handlers
Express wrapper + route handlers (support passport in app router)
Jun 22, 2023
eric-burel
changed the title
Express wrapper + route handlers (support passport in app router)
Express middlewares in route handlers (support passport in app router)
Jun 30, 2023
Hi,
If I understand correctly, so far the Express wrapper only targets API routes, not route handlers. This is a tad more complicated to setup because route handlers use a different structure for the request/response (the web platform ones, built-in node/browser and used by
fetch
) than Express.Can you please confirm me that this is not possible in next-connect right now?
In the meantime here is what I've stated to work on to bypass this issue: https://github.com/Devographics/Monorepo/blob/develop/surveyform/src/app/api/nespresso.ts
The API is like so:
Feel free to reuse this code if that sounds relevant to you. The typings are giving me a hard time (somehow "res.status" is not found, and "Handler" type is not accepted as a middleware) and features are missing but it roughly works otherwise.
After a few more experiments, I fail to properly create an Express response/request directly from Express codebase, this forces me to mimick all features but then writing the request seems to fail.
Setting relevant methods by hand, it mostly works however somehow passport can't set "res.user", I can't tell why, while it can set "_passport". I don't have a minimal repro yet.
The text was updated successfully, but these errors were encountered: