Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Commit

Permalink
fix: swap proxy to cors-anywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
cujarrett committed Feb 4, 2021
1 parent 2f56d6e commit fb8c33c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/integrations/github.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from "node-fetch"
const proxyurl = "https://thingproxy.freeboard.io/fetch/"
const proxyurl = "https://cors-anywhere.herokuapp.com/"

const getContributions = async (username) => {
const contributionYears = await getContributionYears(username)
Expand All @@ -18,7 +18,7 @@ const getContributionYears = async (username) => {
if (process.env.NODE_ENV === "test") {
url = url.replace(proxyurl, "")
}
const response = await fetch(url)
const response = await fetch(url, { headers: { "origin": "glimpse.ninja" } })
const data = await response.text()
const matches = data.match(contributionYearsRegularExpression)
if (!matches) {
Expand All @@ -36,7 +36,7 @@ const getRawContributionData = async (username, contributionYears) => {
if (process.env.NODE_ENV === "test") {
url = url.replace(proxyurl, "")
}
const response = await fetch(url)
const response = await fetch(url, { headers: { "origin": "glimpse.ninja" } })
const data = await response.text()
const contributionRegularExpressionPattern = (year) => `(data-count="\\d*".*data-date="${year}-\\d{2}-\\d{2}")`
const contributionRegularExpression = new RegExp(contributionRegularExpressionPattern(year), "g")
Expand Down

0 comments on commit fb8c33c

Please sign in to comment.