How to configure JIRA API for allowed for cross-origin HTTP request

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to configure JIRA API for allowed for cross-origin HTTP request



I want to integrate my app with JIRA, so when I send request to JIRA server its returns error call 'XMLHttpRequest cannot load https://*********/rest/api/2/project. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.'



This is my code


$http(
method: "GET",
url: "https://***********/rest/api/2/project",
headers:
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*******',
'Access-Control-Allow-Methods': 'GET, POST, DELETE, PUT, OPTIONS',
'Access-Control-Allow-Headers':'X-Requested-With, Content-Type, X-Codingpedia,Authorization'
,
dataType: "jsonp",
).then(function mySuccess(response)
$scope.myWelcome = response.data;
console.log(response.data);
, function myError(response)
$scope.myWelcome = response.statusText;
console.log(response.statusText);
);

};





Why are you adding Access-Control-Allow-Origin headers to a request? Why are you adding a Content-Type to a GET request?
– Quentin
Aug 10 at 9:16


Access-Control-Allow-Origin


Content-Type





Thanks for reply. I try to call from client side so I got this error.So then I call API through back end.Now issue was fixed.
– Lakmi
Aug 10 at 10:17




1 Answer
1



I don't know if you've got the answer, but still..
Just add this into your api server


app.use(function (req, res, next)
if (req.method === "OPTIONS")
// End CORS preflight request.
res.writeHead(204);
res.end();
else
req.fullurl = req.protocol + '://' + req.get('host') + req.originalUrl;
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Credentials', true);

next()
);





JIRA isn't written in Node.js with Express.
– Quentin
Aug 10 at 9:15







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered