Node.js server accepting larger payloads

Hi

I am testing a simple node.js server intended for restful API requests. I tested it with GET and POST requests without any problem. But if I want to send a POST request to the server where the body of the POST is larger than 50 KB, then I get the following error response:

pre>PayloadTooLargeError: request entity too large<br

Is there a way to configure the server to accept larger payloads? Or will this solve itself when I change to a paid version?

I estimate that I will need payloads that can go up to 2 MB.

Hey, @HiwaMobaraz welcome to the forums!

Can you please provide a link to the repl?

oof. Sorry ethan for that post.

No problem. Just dont ask for invite links in the future

yeah I should’ve asked for link

I am a bit confused. The moderator asks for a link, and a normal fellow user apologize for asking for a link hehe. Any how, my repl is public. Is it not possible for you to see it? I only have one repl, started with replit yesterday.

Any how, the code is as simple as it gets. Using node.js it saves post requests to the replit database when correct key is given. It works for POST requests up to a payload of 50 KB. I need like 2 MB payloads.

is this the link? https://replit.com/@HiwaMobaraz/NodeHelloWorldCounter?v=1#index.js also, hehe to what happened before.

Yes you are correct, that is the link.

Basically the way @sonicx180 asked for the link made it sound like they were asking for a join link that lets anybody edit the code and even delete everything. The reason you don’t see that is that it was deleted.

1 Like

Ok, thanks! could you replace line 31 with this? app.use(bodyParser.json({ limit: "2mb" }));
If it doesn’t work, please contact me.

1 Like

Thanks it works up to 1 MB at least. Have not found a way to test with more (the tools i use like cURL or online tools) do not take larger arguments

I could help you test it I think.

Thank you sonix180 <3. YOu are my hero. Note: POSTING to the server with 2MB is not done yet but the server can handle to respond with payloads up to 3.7 MB, which is nice!

Now i am looking into another issue: the server restart once in a while (even when i got Always on repl).
and for some reason, it is really slow during each restart…

I think that is a replit issue. did you boost your repl?

also, could you mark my solution?

Yes, both boost and always on is turned on until tomorrow. Is this a general issue? Note: now i have like 3.7 MB in the database. Dont know if this is related.

database? what database?

Could you move this post to code help?

OK now the solution proposal is marked (as i understand it) and post moved to code help.
Regarding the question “what database”, i am just referring to replit internal database (with max storage of 50 MB)