0

I am using ng2-file-upload Plugin i need to change request method to POST but its showing option

public uploader: FileUploader = new FileUploader({
    url: URL,
    disableMultipart : false,
    autoUpload: true,
    method: 'post',
    itemAlias: 'attachment',
    allowedFileType: ['image', 'pdf']
    });

Request URL: http://1.0.0.188:8080/Auto/upload/data/mandateupload Request Method: OPTIONS Status Code: 403 Remote Address: 10.44.1.7:8080 Referrer Policy: no-referrer-when-downgrade

enter image description here

sridharan
  • 2,011
  • 10
  • 36
  • 61

1 Answers1

0

That's a preflight request that gets triggered anytime you send a non simple request, then, after the preflight or OPTIONS request, your post will be sent. A simple request is one 'GET/HEAD/POST' only containing some of the following headers:Accept, Accept Language, Content-Language, Content-Type and Content Type: application/x-www-form-urlencoded or multipart/form-data or text/plain . So if you want to get rid of OPTIONS before your POST , make your request a simple one.
Maybe your are using an authorization header in your interceptor, which is a common habit, try not adding it when the url is the one corresponding to the file upload.
Or make your back-end accept OPTIONS request, it won't hurt or change your existing functionalities.

Ala Abid
  • 2,256
  • 23
  • 35