无法跨域 REST API 从本地主机调用

Can not do cross domain REST API Call from localhost

我正在尝试使用 JIRA 在 REACT 中提供的 REST API 进行登录。 但我收到类似

的错误
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost:8085' is therefore not allowed access. The response had HTTP status code 403. 
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

下面是我正在测试的登录代码。

fetch("https://jira.company.com/rest/auth/latest/session",{
  method:'POST',
  headers: {
    "Content-Type": "application/json",
    "Access-Control-Allow-Origin" : "*"
  },
  body: 
    JSON.stringify({
    username:"username",
    password : "password"})
  }).then(result => console.log(result));

我也尝试过使用以下参数,但结果相同。

'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',

我还查看了 JIRA API 的文档,但找不到有关跨域请求访问的任何内容。 寻求帮助以进行 API 跨域调用。

尝试设置mode: 'cors'

fetch("https://jira.company.com/rest/auth/latest/session", {
  method: 'POST',
  headers: {
    "Content-Type": "application/json",
    "Access-Control-Allow-Origin": "*"
  },
  mode: 'cors',
  body: JSON.stringify({
    username: "username",
    password: "password"
  })
}).then(function(resp) {
  return resp.json();

}).then(function(data) {
  console.log(data)
});

注意:在演示中您可能会看到 404 这意味着未找到,因为它没有发送用户名和密码