Angular Error 403: Response for preflight does not have HTTP ok status

Discussão em 'Angular' iniciado por Himanshu Jindal, Dezembro 26, 2024.

  1. I have the following post request by which I am trying to upload a PDF FIle on Alfresco Community Version On-Premise Server:

    var urlPost = 'http://127.0.0.1:8080/alfresco/service/api/upload?alf_ticket=' + ticket;
    let header = new HttpHeaders();
    header = header.append("Authorization", "Basic " + btoa("user:passwoed"));
    var formData = {
    filedata: file,
    filename: fileName,
    siteid: 'uploadsite',
    containerid: 'documentLibrary',
    uploadDirectory: '/',
    description: 'Test description',
    contenttype: 'cm:content',
    thumbnails: 'doclib',
    overwrite: 'false',
    };
    this.http.post(urlPost, formData, { headers: header }).subscribe(response => {
    console.log(response);
    }, err => {
    console.log("User authentication failed!");
    });


    But I am getting the following error:

    Error 403: Response for preflight does not have HTTP ok status.


    It works when I hit request with postman.After some research, I have found that I need to change my back-end to not to require authentication for the OPTIONS method, but I am not sure how to do that too.

    I am new here and any help will be appreciated. Thanks!!

    Continue reading...

Compartilhe esta Página