-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
NextApiRequest is not pipe-able readable stream #7912
Comments
Hey @xlambda, you can read stream but you need to provide [config] (https://github.com/zeit/next.js#api-middlewares) to opt-out from body parsing. export const config = {
api: {
bodyParser: false,
},
} |
@huv1k Would it make sense to add a property in // next.config.js
module.exports = {
defaultRouteConfig: {
amp: 'hybrid',
api: {
bodyParser: false
}
}
} which then still can be overriden on a per route basis // pages/the-one-that-is-not-amp.js
export const config = {
amp: false
}
// api/the-one-that-wants-a-parsed-body.js
export const config = {
api: {
bodyParser: true
}
} Reason is that I might use my own library to parse these requests throughout my project, and it wouldn't be very ergonomic to have to declare this export everywhere. |
Hey @Janpot, we have a plan for this feature |
Is there a ticket I can follow? |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
NextApiRequest is suposed to be a Readable Stream by extending http.IncomingMessage, but no data sends to the Writable Stream when piping. Sample code:
I guess the Readable Stream data is consumed when the body attribute is initiated, so I modify the above code as to
and it does work.
The text was updated successfully, but these errors were encountered: