0

When I call API to POST Request I get error 403 and "has been blocked by CORS Policy.

This is my Ajax Code:

$.ajax({
    type: "POST",
    enctype: 'multipart/form-data',
    url: $('meta[name="server-config"]').attr('content') + "/file/upload/?user_id=" + response.user_id,
    data: data,
    headers: {
        'Authorization': `Bearer ${$('meta[name=auth-key]').attr('content')}`
    },
    processData: false,
    contentType: false,
    cache: false,
    timeout: 3000,
    success: function (data) {
        console.log(data)
        // location.reload();
    },
    error: function (e) {
        console.log("ERROR : ", e);
    }
});

Sam N Den
  • 57
  • 6
  • 13

1 Answers1

0

In your post method file add the following header and try

header('Access-Control-Allow-Origin: *');
gauri
  • 121
  • 1
  • 3
  • 14