Skip to content
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

Reading request bodies in middleware breaks API requests #37805

Closed
1 task done
AliYusuf95 opened this issue Jun 18, 2022 · 2 comments · Fixed by #37806
Closed
1 task done

Reading request bodies in middleware breaks API requests #37805

AliYusuf95 opened this issue Jun 18, 2022 · 2 comments · Fixed by #37806
Labels
bug Issue was opened via the bug report template.

Comments

@AliYusuf95
Copy link
Contributor

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

    Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64
    Binaries:
      Node: 16.15.1
      npm: 8.11.0
      Yarn: 1.22.15
      pnpm: 7.2.1
    Relevant packages:
      next: 12.1.7-canary.41
      react: 17.0.2
      react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

I'm trying to implement ory kratos self-service login flow. As their documentation, I used @ory/integrations package to integrate with Next.js. The integration basically utilizes the next API paths to proxy incoming requests to ory kratos instance. This approach works fine until [email protected]. This release brings the ability to read the body in middleware #34519. This feature breaks the ability to correctly proxy requests (specifically pip and other req functions usage).

Expected Behavior

Should be able to utilize the full functionality of request IncomingMessage API without losing context.

Link to reproduction

https://github.com/AliYusuf95/kratos-selfservice-ui-react-nextjs

To Reproduce

1- Try to send a POST request method to http://localhost:3000/api/test and observe the response method and headers, then remove/rename middleware.ts file and try again.

2- Follow the documentation page to run ory kratos instance, the project will not work if middleware.ts is present.

@AliYusuf95 AliYusuf95 added the bug Issue was opened via the bug report template. label Jun 18, 2022
AliYusuf95 added a commit to AliYusuf95/next.js that referenced this issue Jun 18, 2022
@AliYusuf95
Copy link
Contributor Author

Reference related issue in ory/integrations#34

@kodiakhq kodiakhq bot closed this as completed in #37806 Jun 27, 2022
kodiakhq bot pushed a commit that referenced this issue Jun 27, 2022
…#37806)

Closes: #37805

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`


Co-authored-by: JJ Kasper <[email protected]>
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant