question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NextJS: API resolved without sending a response for /xx/xx, this may result in stalled requests.

See original GitHub issue

Checks

Describe the bug (be clear and concise)

I’m trying to setup local proxy while it’s working fine for all the requests, it doesn’t work for POST requests including data. I have disabled bodyParser but it didn’t help.

I also created an issue about this but it doesn’t seems to be next.js issue but I’m not sure. Issue: https://github.com/vercel/next.js/issues/36811 Discussion: https://github.com/vercel/next.js/discussions/36859

Step-by-step reproduction instructions

1. create api in next project
2. send a post request including data (like a login api)
3. you will see that the request won't be resolved

Expected behavior (be clear and concise)

I expect to resolve the api with a response.

How is http-proxy-middleware used in your project?

=> Found "http-proxy-middleware@2.0.6"
info Has been hoisted to "http-proxy-middleware"
info This module exists because it's specified in "devDependencies".
info Disk size without dependencies: "184KB"
info Disk size with unique dependencies: "592KB"
info Disk size with transitive dependencies: "2.83MB"
info Number of shared dependencies: 11
✨  Done in 0.44s.


### What http-proxy-middleware configuration are you using?

```typescript
const proxy = createProxyMiddleware({
      logLevel: 'debug',
      target: 'XXX',
      changeOrigin: true,
      autoRewrite: true,
    });

export default proxy;

What OS/version and node/version are you seeing the problem?

macOS, node 16

Additional context (optional)

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JacerOmricommented, Nov 14, 2022

I was stuck with this for a while. I was able to solve it using API config (in Next.js), I had to disable bodyParser.

export const config = {
  api: {
    externalResolver: true,
    bodyParser: false, // I added this
  },
0reactions
jag-ermeistercommented, Dec 13, 2022

I was stuck with this for a while. I was able to solve it using API config (in Next.js), I had to disable bodyParser.

export const config = {
  api: {
    externalResolver: true,
    bodyParser: false, // I added this
  },

Just in case anybody is unable to read like me, I originally misinterpreted this and added bodyParser: false to the middleware configuration, which did not help. Adding this to the Next.js API config like @JacerOmri mentioned was the fix!

Read more comments on GitHub >

github_iconTop Results From Across the Web

API resolved without sending a response for /XXXX ... - GitHub
API resolved without sending a response for /XXXX/XXXX, this may result in stalled requests.
Read more >
NextJs - Node - API resolved without sending a response for ...
I wrapped the sendmail call in a promise and that seems to have worked. var promise = new Promise( (resolve, reject) => {...
Read more >
Static Site Generation with Next.js and TypeScript (Part II)
js application. Below, I'm going to show you how to fetch data from an API with getStaticProps . Installation and Setup ...
Read more >
WebSockets and Node.js - testing WS and SockJS by building ...
This post will look at implementing a couple of low-level WebSockets libraries with Node.js as the WebSocket server. We'll look at how each...
Read more >
Build a Next.js Application with TypeScript - Okta Developer
Learn how to use Typescript to build a Next.js application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found