I'm building an app where angular front-end is on s3 as static website and Sails (0.10.3) API inside dokku with Node 0.11.13 and SSL on EC2. If file is larger than about 4mb I got error "No 'Access-Control-Allow-Origin' header is present on the requested resource." OPTIONS request is hitting my API and I can catch it in customMiddleware but the POST with data is not reaching that far. On front-end side I'm using angularjs-file-upload. If I turn off SSL then it works without any problems but I would prefer to keep it on.
I went up the chain app itself -> dokku -> SSL and the problem was even higher, in nginx.
nginx.conf required one line more: proxy_read_timeout 1200s;
One more thing you can try, if it's Nginx that's causing issues. Look into your error log file. Generally its /var/log/nginx/error.log
In that if you see this line
*133774 client intended to send too large body: 3141911 bytes
It means the issue is of the size and you might wanna fix it.
The way you do it is in your nginx.conf in the HTTP context paste this anywhere.
client_max_body_size 50M;
This will allow you to increase your body size to 50M.
Hence fixing the issue
I went up the chain app itself -> dokku -> SSL and the problem was even higher, in nginx.
nginx.conf required one line more: proxy_read_timeout 1200s;
I had a similar solution and I solved it with the help of this. It's because of the client_max_body_size
configuration variable that Nginx has.
1.Go to nginx configuration setting file:
sudo nano /etc/nginx/nginx.conf
2.Change in nginx.conf file:
http {
clientmaxbody_size 100m;
}
3.Restart Your Nginx:
sudo service nginx restart
or
service nginx reload
for my MEAN Stack (node & Expreess js) application it worked. Hoping for your case too !
Another EXPRESS code if 1,2 & 3 point won't work for you
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors());
Below link for reference full detail explanation: https://www.digitalocean.com/community/questions/how-to-edit-nginx-setting-for-big-file-upload
client_max_body_size 100m;
–
Arcanum © 2022 - 2024 — McMap. All rights reserved.