【问题标题】:How to resolve 'Cross Origin domain' issue without using 'CORS' chrome extension using Javascript to access JIRA REST API如何在不使用“CORS”chrome 扩展的情况下解决“跨域域”问题,使用 Javascript 访问 JIRA REST API
【发布时间】:2018-08-23 22:41:48
【问题描述】:

我开发了一个应用程序来访问 JIRA REST API。通过添加 'CORS' chrome 扩展,我可以通过启用 'CORS' 从 http://localhost:8000 获取数据

但如果没有 CORS 扩展,该应用程序将无法运行。 有人可以告诉我有没有办法在没有“CORS”扩展的情况下访问 REST API。

【问题讨论】:

  • How to resolve 'Cross Origin domain' issue without using 'CORS' chrome extension - 只有一种方式(客户端)... 服务器 需要允许跨源资源共享 - 或者,用于服务器网页的服务器可以代理请求服务器 -> 客户端的服务器

标签: javascript rest cors


【解决方案1】:

对我来说,它通过以下步骤起作用:

在 manifest.json 中添加一个属性

"permissions": [
        "activeTab",
        "tabs",
        "notifications",
        "http://*/",
        "https://*/"
    ]

并尝试使用 jquery 请求其余 API

  var settings = {
    "async": true,
    "crossDomain": true,
    "url": "your jira server URL",
    "method": "GET",
    "headers": {
      "authorization": "Basic <base64  username:password>",
      "cache-control": "no-cache"
    }
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-22
    • 1970-01-01
    • 2017-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 2017-05-28
    相关资源
    最近更新 更多