Closed AliYusuf95 closed 2 years ago
Thank you so much for the report! If you have any ideas how to fix that easily for NextJS >= 12.1.1 we'd be very thankful :)
@aeneasr I don't have much experience in streams, and since next request implementation can be changed at any time, I think it's better to send a new request instead of stream it.
@AliYusuf95 I can not reproduce the issue you're describing. I have upgraded NextJS ( https://github.com/ory/kratos-selfservice-ui-react-nextjs/pull/35 ) and added a middleware ( https://github.com/ory/kratos-selfservice-ui-react-nextjs/pull/36 ) but could not reproduce the described issue. Can you double check?
@aeneasr I think you need to update next in the dependencies to take the effect.
@aeneasr the change is in peerDependencies
🤦
I can reproduce this now :)
I looked into it but am not really sure what's broken. I did see that they had other issues with the middleware and API handling in general. The problem probably is that they're now automatically reading the body in the middleware and are not respecting the bodyParser: false
instruction. I think that leads to the request having a "spoiled" body buffer which then breaks the request piping. But I'm not sure how to fix that, maybe it has to be reported at NextJS as a bug / regression, because I think it actually is a regression in NextJS. Would you be down to open such an issue?
@aeneasr Sure, I think I identified the reason that cause the issue .. I'll open an issue in NextJS to fix it
The issue has fixed by https://github.com/vercel/next.js/pull/37806, and available in next@v12.1.7-canary.50
Great job!!
I'm trying to implement Self-Service login flow. I checked the repo mentioned in the documentation page (kratos-selfservice-ui-react-nextjs).
The project works fine until
next@12.1.0
. However afternext@12.1.1
it seems the changes introduce in the middleware logic, specifically this PR https://github.com/vercel/next.js/pull/34519 breaks the integration with ory kratos. Where transforming the request body to web stream and convert it back to nodejs stream somehow breaks proxying requests of nexjs integration, which leads to send all requests asGET
requests to kratos.To reproduce the issue use kratos-selfservice-ui-react-nextjs and upgrade next to
next@12.1.1
or latest and add a basic middleware:From the browser network I can see the login POST request
http://localhost:3000/api/.ory/self-service/login?flow={id}
is responded with redirect (303) tohttp://localhost:3000/login?flow={id}
And this is the log from kratos instance: