Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
Express: Error at readStream

Server is throwing this error, when client-side app is trying to send a POST request with base64-encoded image.

Error
    at readStream (/Users/.../node_modules/raw-body/index.js:196:17)
    at getRawBody (/Users/.../node_modules/raw-body/index.js:106:12)
    at read (/Users/.../node_modules/body-parser/lib/read.js:76:3)
    at jsonParser (/Users/.../node_modules/body-parser/lib/types/json.js:127:5)
    at Layer.handle [as handle_request] (/Users/.../node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/.../node_modules/express/lib/router/index.js:317:13)
    at /Users/.../node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/.../node_modules/express/lib/router/index.js:335:12)
    at next (/Users/.../node_modules/express/lib/router/index.js:275:10)
    at cors (/Users/.../node_modules/cors/lib/index.js:179:7)
    at /Users/.../node_modules/cors/lib/index.js:229:17
    at originCallback (/Users/.../node_modules/cors/lib/index.js:218:15)
    at /Users/.../node_modules/cors/lib/index.js:223:13
    at optionsCallback (/Users/.../node_modules/cors/lib/index.js:204:9)
    at corsMiddleware (/Users/.../node_modules/cors/lib/index.js:209:7)
    at Layer.handle [as handle_request] (/Users/.../node_modules/express/lib/router/layer.js:95:5)

I've doublechecked the request body: base64 string is not malformed. If app is sending the same request without base64 part, everything goes ok.

server.js:

import http from 'http'
import express from 'express'
import cors from 'cors'
import morgan from 'morgan'
import bodyParser from 'body-parser'
import api from './api'
import config from './config'

let app = express()
app.server = http.createServer(app)

// logger
app.use(morgan('dev'))

// 3rd party middleware
app.use(cors({
    exposedHeaders: config.corsHeaders
}))

app.use(bodyParser.json({
    limit : config.bodyLimit
}))

app.use(express.static("./assets"))

// api router
app.use('/api', api)

app.server.listen(process.env.PORT || config.port)

console.log(`Started on port ${app.server.address().port}`)

export default app

api.js

import { Router } from 'express';
const router = Router();

router.post('/createPost', require('./methods/createPost').default)

export default router
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think it's the same as this issue:

Error: request entity too large

Body parser's limit is set too low (the default is 100k).

In my case, I found that setting limit: '50mb' as described in the solution in the link above fixed my issue:

app.use(bodyParser.json({limit: '50mb'}));

It looks like your limit is being set in config.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!