Hi
Could you help me to implement file upload with parse server on client side and on server side.
I have this error when I try to upload:
XMLHttpRequest cannot load https://evening-plateau-93592.herokuapp.com/parse/files/avatar.png. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://cyboolo.worldsecuresystems.com' is therefore not allowed access.
I have updated middleware.js with last commit but still the same problem.
Before migration to parse server, on client side, I used:
`myDropzone.on("addedfile", function(myfile) {
if(myfile && (myfile.size<3000000)){
var name = "avatar.png";
var parseFile = new Parse.File(name,myfile);
parseFile.save().then(function(){
Parse.Cloud.run("modify_avatar", {A:parseFile},{
success: function(reponse){
//on cloud code I attached the file path to User class.
},
error: function(error){ console.log(error); }
});
}, function(error){});
////
}
});`
That worked perfectly but now with parse server I do not know how to make it work.
I have my db on mongodb and deployed parse server on heroku. Everything is working fine except this file upload that I can't manage.
Thank you for your help.
I think that CORS is not enabled in the Parse-server example. You can use the cors module for that.
In the index.js:
var cors = require('cors'); // import the module
....
var app = express();
app.use(cors()); // Enable CORS
2.1.3 included a change to cors headers. Should be fixed. Please re-open if not. Thanks.
Hi!
XMLHttpRequest cannot load http://localhost:1337/parse/files/1456700001722.png. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:1337' is therefore not allowed access.
Is this solved? i get the same problem when uploading bigger file, like 1mb
try to change client_max_body_size in nginx
Most helpful comment
Hi!
XMLHttpRequest cannot load http://localhost:1337/parse/files/1456700001722.png. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:1337' is therefore not allowed access.