使用 cors Anywhere 代理对 Jira Cloud API 执行 POST 时出现 403

发布于 2025-01-15 22:49:29 字数 1437 浏览 3 评论 0原文

如果这个问题已经解决,请原谅我,我已经浏览了我能找到的所有过去的相关问题,但无法找到可行的解决方案。

我正在使用 javascript 构建一个小型 Figma 插件,以允许用户从 Figma 在 JIRA 中创建票证。由于 Figma 有效地作为基于浏览器的应用程序运行,因此按照此处过去问题的建议,我通过 cors Anywhere 代理(Heroku)执行请求,遵循 堆栈溢出帖子

我使用以下代码和 POST 请求来执行此操作。

const basicAuth = buffer__WEBPACK_IMPORTED_MODULE_6__.Buffer.from(username + ‘:’ + password).toString(‘base64’);
// where password is the API token

const bodyData = { "fields": { "summary": "Main order flow broken", "issuetype": { "id": "10000" }, "project": { "id": "10000" }, "customfield_10011" : "Test" } };

fetch(https://fierce-spire-09192.herokuapp.com/https://${companyName}.atlassian.net/rest/api/3/issue, {
method: ‘POST’,
headers: {
‘Authorization’: ${basicAuth},
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘X-Atlassian-Token’: ‘nocheck’
},
body: bodyData
})

但是,当我提出请求时,我收到以下错误。

POST https://fierce-spire-09192.herokuapp.com/https://flighthealthtest.atlassian.net/rest/api/3/issue 403 (Forbidden)
Response: 403 Forbidden
XSRF check failed

当我在 Postman 中尝试非代理 URL(从头开始删除 heroku 应用程序 URL,因此只需“https://flighthealthtest.atlassian.net/rest/api/3/issue”)并发出相同的 POST 请求时,它工作完美。当我在 Postman 中使用代理 URL 时,它不起作用,并生成:

“缺少必需的请求标头。必须指定以下之一:origin、x-requested-with”。

有谁知道我如何解决这个问题?非常感谢!

Forgive me if this has been solved, I’ve looked through every past related question I could find and was not able to get a working solution.

I’m building a small Figma plugin using javascript to allow users to create tickets in JIRA from Figma. Since Figma effectively runs as a browser-based application, following the advice of past questions on here I am doing the request through a cors anywhere proxy (Heroku), following the advice of the first answer in a stack overflow post.

I’m using the following code and POST request to do this.

const basicAuth = buffer__WEBPACK_IMPORTED_MODULE_6__.Buffer.from(username + ‘:’ + password).toString(‘base64’);
// where password is the API token

const bodyData = { "fields": { "summary": "Main order flow broken", "issuetype": { "id": "10000" }, "project": { "id": "10000" }, "customfield_10011" : "Test" } };

fetch(https://fierce-spire-09192.herokuapp.com/https://${companyName}.atlassian.net/rest/api/3/issue, {
method: ‘POST’,
headers: {
‘Authorization’: ${basicAuth},
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘X-Atlassian-Token’: ‘nocheck’
},
body: bodyData
})

However, I’m getting the following error when I make the request.

POST https://fierce-spire-09192.herokuapp.com/https://flighthealthtest.atlassian.net/rest/api/3/issue 403 (Forbidden)
Response: 403 Forbidden
XSRF check failed

When I try the non-proxied URL (removing the heroku app URL from the beginning, so just "https://flighthealthtest.atlassian.net/rest/api/3/issue") in Postman and make the same POST request, it works perfectly. When I use the proxied URL in Postman, it does not work, and produces:

“Missing required request header. Must specify one of: origin,x-requested-with”.

Does anyone have ideas as to how I can resolve this? Thanks so much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文