mercredi 4 octobre 2017

Sending headers with Ajax [duplicate]

This question already has an answer here:

I have 2 domains Frontend_service and Backend_service(API).

I'm trying to make AJAX request with header and it's doesn't work.

  $.ajax({
        type: 'GET',
        crossDomain: true,
        url:"http://ift.tt/2wx2M4J",
        headers: {
            "XAUTH_KEY": "secret"
        }
    }).done(function (data) {
        alert(data);
    });

}

XAUTH_KEY it's some key to open access to API. My API works fine, I checked it with Postman. Here's error:

Accept:*/* 
Accept-Encoding:gzip, deflate 
Accept-Language:en-US,en;q=0.8 
Access-Control-Request-Headers:xauth_key 
Access-Control-Request-Method:GET 
Connection:keep-alive  
Host:backend_service.com 
Origin:frontend_service.com 
Referer:frontend_service.com/… 
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/61.0.3163.100 Safari/537.36

Obviously, header wasn't sent. But WHY?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire