Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Cors error whenconnecting to local jira server instance

Deepika Jain
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 2, 2019

As suggested in lots of posts, I have tried almost all the solutions, I have installed jira server on local and using React js for writing rest calls,

Added localhost:3000 in the whitelist and tried disabling whitelist too.

Below is the error I am getting:

Access to fetch at 'http://localhost:8080/rest/api/2/issue/DUM-1/' from origin 'http://localhost:3000' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

 

Below is the code snippet:

 

const url = "http://localhost:8080/rest/api/2/issue/DUM-1/";

fetch(url, {

method: 'GET',

headers: { 'Origin': 'http://localhost:3000',

'Content-type': 'application/json', 'Accept': 'application/json',

'Authentication': 'Basic ZGVlcGlrYWpuMDI6ZGVlcGFAMTAxMA==',

'Access-Control-Allow-Origin': "*",

'Access-Control-Allow-Methods': 'GET, POST, PATCH, PUT, DELETE, OPTIONS',

'Access-Control-Allow-Headers': "Origin, X-Requested-With, Content-Type, Accept, X-Auth-Token" } })

.then(response => response.json()) .then(json => {console.log(json)}) // .then(data => this.setState({ data })) .catch(error => console.log('Authorization failed : ' + error));

 

Thanks,

2 answers

0 votes
Mohit Kumar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 11, 2023

@Deepika Jain  Hello Deepika, I am facing the same issue. Can you please help me to resolve the issue because it is very urgent for me. It would be great help

0 votes
Mohamed Basith
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 1, 2019

@Deepika Jain I m facing the same , u got solution ? 

Mohit Kumar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 11, 2023

@Mohamed Basith Hello brother any solution you got? because I am facing the similar issue 

Suggest an answer

Log in or Sign up to answer