3

I'm getting an 413 request entity too large when I make a request from my nodejs application inside Docker to an outside REST API.

When I make this request outside Docker, it goes normally.

I was using node 10.16.0 and updated to 12.16.1 without success.

Dockerfile:

FROM node:12.16.1

RUN mkdir -p /usr/share
RUN cd /usr/share

WORKDIR /app

ADD . /app
RUN yarn
EXPOSE 4000
CMD ["node", "index.js"]

Error on /Document/PostDocument (413): "<html>\r\n<head><title>413 Request Entity Too Large</title></head>\r\n<body>\r\n<center><h1>413 Request Entity Too Large</h1></center>\r\n<hr><center>openresty/1.15.8.1</center>\r\n</body>\r\n</html>\r\n"
  • 1
    are you using Express? And somehow limit the size of the body? If so, you may find [the answer to this question](https://stackoverflow.com/questions/19917401/error-request-entity-too-large) useful. In any case, what you pasted is the client log. You'd probably make a good use of the server's log to learn more about the error. [The answer to this question](https://stackoverflow.com/questions/10815218/where-is-nodejs-log-file) may help. – pehuen Mar 02 '20 at 21:04
  • I'm not using Express. The problem is on the client, which is my nodejs application. The server is remote and has no problem when I can with my application outside docker or via Postman. I'm going to edit my question – Alan Marcell Mar 03 '20 at 13:55
  • Then it certainly looks like the body you're sending in the POST request from your app inside Docker is somehow different from the one on postman. Have you tried hardcoding or logging it? You could also try debugging your app inside node to take a peek on the shape of the body. [This explains how to config if you're in VS code](https://code.visualstudio.com/docs/containers/debug-node). – pehuen Mar 04 '20 at 15:52
  • Yes, I've saved the content to a file and tested in Postman. Note that the request work on application when running outside Docker. – Alan Marcell Mar 04 '20 at 18:30

0 Answers0