skip to Main Content

I have converted a image to base64 that are in my react.js application register form. It covert this image and send it to Node.js server with MySQL database. In here axios post request is not is unsuccessful because converted url is very large.

frontend console shows net::ERR_FAILED 431 (Request Header Fields Too Large). Is there any way to handle this

2

Answers


  1. Nodejs, by default, has a smaller limit for request body, which is what you seem to be running into. The limit can be increased using code snippet below in nodejs while initializing the body parser package

    app.use(bodyParser.urlencoded({limit: '10mb'}));
    

    You can read more on the defaults and other settings here

    Login or Signup to reply.
  2. Instead of sending the image data as base64, you can upload the image file directly to the server if you don’t want resize it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search