Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File upload - No 'Access-Control-Allow-Origin' #547

Closed
cyboolo opened this issue Feb 21, 2016 · 5 comments
Closed

File upload - No 'Access-Control-Allow-Origin' #547

cyboolo opened this issue Feb 21, 2016 · 5 comments

Comments

@cyboolo
Copy link

cyboolo commented Feb 21, 2016

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.

@IlyaDiallo
Copy link
Contributor

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

@gfosco
Copy link
Contributor

gfosco commented Feb 26, 2016

2.1.3 included a change to cors headers. Should be fixed. Please re-open if not. Thanks.

@gfosco gfosco closed this as completed Feb 26, 2016
@Avatarchik
Copy link

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.

@ljunokas
Copy link

Is this solved? i get the same problem when uploading bigger file, like 1mb

@YassineBaggar
Copy link

try to change client_max_body_size in nginx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants