Search code examples
node.jsreactjsaxiosbase64

Post Base64 converted image to Node.js Backend


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


Solution

  • 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


    If you are using querystring to send the data to Node, try updating the code to send it as an HTTP POST with appropriate request body