FineUploader - add authentication in title

I am using FineUploader 3.7 in a crossload project. Everything is fine until I transfer the code to the DEV client server, which has simple authentication. Is there a way to insert authentication information into a form when a preflight mail request is sent to the server?

I tried to include basic auth in the headers, but it didn't work. See the following code:

$.ajaxSetup({ headers: { 'Authorization': "Basic YZVjaGFmbWluOkNieWxjBTY3" }, beforeSend: function (jqXHR, settings) { jqXHR.setRequestHeader('Authorization', 'Basic YZVjaGFmbWluOkNieWxjBTY3'); } }); 

And even more, I tried setting a custom header and with no luck:

 var manualuploader = new qq.FineUploader({ customHeaders: { 'Authorization': 'Basic YXVjaGFkbWluOkNieWxjZTY3' },.... 
+6
source share
1 answer

Your customHeaders parameter customHeaders not defined correctly. customHeaders is a property of the request option, as described in the request documentation.

Your integration code with your software should look like this:

 var manualuploader = new qq.FineUploader({ request: { endpoint: "path/to/your/server", customHeaders: { "Authorization": "Basic YXVjaGFkbWluOkNieWxjZTY3" } } }); 

Also, keep in mind that jQuery ajaxSetup does not affect ajax / xhr Fine Uploader calls. Fine Uploader does not use jQuery at all inside. The optional jQuery plugin offered by Fine Uploader simply wraps its own javascript library to allow it to be easily used as a jQuery plugin, supporting the common syntax associated with jQuery and jQuery plugins.

Also, keep in mind that these headers will not be sent along with the download request in IE9 and later, since IE9 and later do not support downloading via ajax / xhr. In these browsers, an iframe-oriented form is submitted. If you submit the form, you cannot associate custom headers with the request.

+9
source

Source: https://habr.com/ru/post/952557/


All Articles