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

Edge API endpoints can't read the body in next start and next dev #37821

Closed
1 task done
Schniz opened this issue Jun 19, 2022 · 1 comment · Fixed by #37822
Closed
1 task done

Edge API endpoints can't read the body in next start and next dev #37821

Schniz opened this issue Jun 19, 2022 · 1 comment · Fixed by #37822
Labels
bug Issue was opened via the bug report template.

Comments

@Schniz
Copy link
Contributor

Schniz commented Jun 19, 2022

Verify canary release

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

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000
Binaries:
  Node: 16.13.1
  npm: 8.1.2
  Yarn: 1.22.18
  pnpm: 7.3.0
Relevant packages:
  next: 12.1.7-canary.41
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

How are you deploying your application? (if relevant)

Describe the Bug

With the runtime set to edge, it seems the request body is always empty (e.g. POST requests), or am I missing something?

Originally posted by @zaiste in #37481 (comment)

Expected Behavior

await request.text() if a POST request with a body occurred

Link to reproduction

To Reproduce

Create a new /api/edge.js file with the content:

export default async (req) => new Response(`got: ${await req.text()}`)
export const config = { runtime: 'experimental-edge' }
  • run next dev --port=1234
  • run curl http://localhost:1234/api/edge -X POST -d 'hello world'

This will fail.

@Schniz Schniz added the bug Issue was opened via the bug report template. label Jun 19, 2022
@kodiakhq kodiakhq bot closed this as completed in #37822 Jun 20, 2022
kodiakhq bot pushed a commit that referenced this issue Jun 20, 2022
This PR enables Edge API endpoints to receive a body.
This wasn't in the original PR, as thankfully pointed out by @zaiste in [this comment](#37481 (comment)) 🙏

## Related

- Fixes #37821

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
@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 20, 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.

2 participants
@Schniz and others