2 years ago
I am have an issue with 413 PayloadTooLargeError when I try to upload 2.4 Mb image
Cloudinary limit is 10 Mb
Strapi limits that I set is 250 Mb
plugings.js
module.exports = ({ env }) => ({ upload: { config: { sizeLimit: 250 * 1024 * 1024,
middlewares.js
{ name: "strapi::body", config: { formLimit: "256mb", jsonLimit: "256mb", textLimit: "256mb", formidable: { maxFileSize: 250 * 1024 * 1024, }, }, },
I am wondering maybe I need also to configure nixpacks.toml or something like that to prevent this issue
11 Replies
2 years ago
Railway does not have a max upload size limit, I have uploaded files many times that size without issue.
The only relevent limitation would be a 5 minute time limitation, but you would not get back 413.
There is something in your project that is limiting the upload size.
2 years ago
The thing is that it works locally, no limitations
Ok, I will try to invistigate further
2 years ago
Does node.js on railway use nginx?
https://docs.strapi.io/dev-docs/plugins/upload#max-file-size
You may also need to adjust any upstream proxies, load balancers, or firewalls to allow for larger file sizes.
(e.g. Nginx has a config setting called clientmaxbody_size that will need to be adjusted since it's default is only 1mb.)
2 years ago
Wish I could tell you what it was, but I can promise you with up most certainty that there is not a platform limitation preventing you from uploading a 2.4mb file.
A standard node.js deployment does not use NGINX, and neither does Railway.
2 years ago
If you wanted extra reassurance of this not being an issue with the platform, you can test for yourself -
2 years ago
When I change local upload provider to Cloudinary, I receive 413 as well. Probably I should check why
I am able to upload via admin panel, but no via /api/upload POST
The issue is not connected to railway
2 years ago
After investigation, the problem is on client side. I am cropping image and convert it to blob, and in result somehow its size converts from 2.4 Mb to 10.53 Mb and doesn't meet Cloudinary limit.
So the issue with converting to blob, which may be non-obvious in terms of file-size
Status changed to Solved Railway • over 1 year ago
2 years ago
More information for those who might have the same issue:
https://github.com/fengyuanchen/cropper/issues/542
.toBlob(…, 'image/jpeg', 90); will help