-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next.js middleware breaks api request #34
Comments
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 ( ory/kratos-selfservice-ui-react-nextjs#35 ) and added a middleware ( ory/kratos-selfservice-ui-react-nextjs#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 |
🤦 |
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 |
@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 vercel/next.js#37806, and available in [email protected] |
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
[email protected]
. However after[email protected]
it seems the changes introduce in the middleware logic, specifically this PR vercel/next.js#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
[email protected]
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:
The text was updated successfully, but these errors were encountered: