octokit / rest.js

GitHub REST API client for JavaScript
https://octokit.github.io/rest.js
MIT License
525 stars 62 forks source link

[BUG]: HttpError: Failed to fetch (CORS policy) #397

Open mchestnut opened 5 months ago

mchestnut commented 5 months ago

What happened?

We are seeing sporadic POST requests using octokit/rest.js failing. The requests come back with the error HttpError: Failed to fetch and Access to fetch at 'https://api.github.com/repos/ChapmanAutoGroup/sites.retail/git/trees' from origin [our site] has been blocked by CORS policy: 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.

We're calling the git.createTree and git.createBlob methods. We have seen it fail on either one at different times.

We've also noticed that attempting the same exact request using the same headers and payload will eventually result in a success, although the number of retries can vary from 1 to over a dozen.

The library is being using in a Vue app. We've seen the error running both locally and on a production server.

Any ideas what is causing the CORS issue?

Versions

node: 18.17.1 @octokit/rest: 20.0.2

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 5 months ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

wolfy1339 commented 2 months ago

This seems more like a GitHub infrastructure issue than an issue with Octokit itself