Can I set item.withCredentials to false? #140
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I have been having a problem with the post. When I click 'upload all' the progress bar moves but it never actually posts the file. I don't see any errors.
I stumbled across the problem on line 329 of file-uploader.ts.
xhr.withCredentials = item.withCredentials;
If I change this to xhr.withCredentials = false; it will work.
Is there a way to set this as a property from outside?
I am setting the authToken. When withCredentials is false I get the post on the server side and it is authenticated. My angular2 client is a different site than the webApi it calls. CORS is setup and I am getting the post when withCredential is false.
I'm not really sure what this is doing but I know if has something to do with cross-site scripting.
Can I set it to false from outside?
Is that the proper fix?
I suggest you extending the uploader class and set the flag when a file is added:
@chambersDon you should probably add your server domain address to your Access-Control-Allow-Origin header. I assume it's either not set or set with the wild card : *. Which is not authorized if you don't set the credentials to false in the XHR option (withCredentials = false).
@JulioC I also need to change the credentials option. Extending the class works but it could be great to add a withCredential option at the FileUploader constructor level, like this :
new FileUploader({url: 'http://server/api', withCredentials: false});
@cm0s - could you possibly provide the code to extend the class? I've been trying for a few hours and can't seem to get it to work.
You can disable sending withCredentials before file upload:
Is there a way to set withCredentials: false in options or just one globally instead onBeforeUploadItem
@neilhem's answer just saved my day. All I could figure out before reaching this post by sheer Google power was that my
uploaderwas only sending an OPTIONS request and nothing else... Hard to fix.Since this ticket is still open, may I suggest logging some sort of warning to let the dev know why nothing is beeing uploaded ? Many thanks.
Yeah, this is sad that we need so many time to figure out way disabling some options. @valorkin can we suggest PR to add a line into docs?
Docs is always good yes, but if it's acceptable in that case I think logging some hints in the console would help a lot. I usually search the documentation based on what I understand of the problem, and in that case, there was literally no clue.