2

My frontend is made on Vue.js and is running on nginx in production. My nginx.conf looks like:

server {
    listen                  80;
    server_name             localhost;

    root                    /usr/share/nginx/html;
    index                   index.html index.htm;

    client_max_body_size    100M;

    # added for VueRouter
    location / {
        try_files $uri $uri/ /index.html;
    }
}

In Node.js app I have this endpoint using multer to accept file:

// 100 MB
const upload = multer({ storage, limits: { fileSize: 100 * 1024 * 1024 } })

const router = express.Router()
router.post('/create', upload.single('file'), ImageController.create)

Also in app.js I have bodyParser set to 100 MB:

const app = express()

// Middleware
app.use(bodyParser.urlencoded({ limit: '100mb', extended: true, parameterLimit: 100000 }))
app.use(bodyParser.json({ limit: '100mb' }))

But I still get the error

413 Request Entity Too Large

Am I missing something?

2
  • Is there any server (like nginx, for example) sitting in between the client and the node server? Commented Apr 11, 2019 at 12:21
  • @raina77ow I updated my question, I use nginx on frontend Commented Apr 11, 2019 at 12:25

1 Answer 1

3

I managed to fix it and the problem was nothing as I expected. In my VPS I create docker network nginx-proxy to link different ports to different domain names. I had to add client_max_body_size 100M; to nginx.conf of that container too!

Sign up to request clarification or add additional context in comments.

1 Comment

I had the same POST error so I first just configure nginx.conf client_max_body_size 1G; and it was not necessary modify multer and body.parser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.