I am calling custom rest api of JIRA server №1 from frontside JIRA Server 2 .
var myHeaders = {
'Authorization': 'Basic ' + btoa(...)
};
$http.get(url, {
headers: myHeaders
})
.then(function successCallback(response) {
});
})
Jira server №1 is in white list of Jira server №2 with type Application link and active Allow Incoming.
Custom rest api returned headers (I checked in SOAP UI):
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: OPTIONS, GET, PUT, DELETE
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token
Access-Control-Expose-Headers: Origin, Authorization, Content-Type
Although, it’s not working. I get the error:
Access to XMLHttpRequest at IRA server №1’s url from origin JIRA server №2’s url has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
@Path("test")
public class TestResource {
@GET
@Produces({MediaType.APPLICATION_JSON})
public Response getTest() throws Exception {
return Response.ok()
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "OPTIONS, GET")
.header("Access-Control-Allow-Headers", "Origin, Content-Type, X-Auth-Token, Access-Control-Allow-Headers, Authorization, X-Requested-With,observe")
.header("Access-Control-Expose-Headers", "Origin, Authorization, Content-Type, responseType, observe")
.header("Access-Control-Max-Age", "3600")
.build();
}
@OPTIONS
public Response optionsTest(){
Response r = Response.ok()
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "OPTIONS, GET")
.header("Access-Control-Allow-Headers", "Origin, Content-Type, X-Auth-Token, Access-Control-Allow-Headers, Authorization, X-Requested-With,observe")
.header("Access-Control-Expose-Headers", "Origin, Authorization, Content-Type, responseType, observe")
.build();
return r;
}
}
What’s wrong?