502: Bad Gateway on freeCodeCamp website?

502: Bad Gateway on freeCodeCamp website?
0

I’m using the freeCodeCamp api to get user data in a Node app, and I used to be able to get data just fine, but it’s recently been returning 502: Bad Gateway. Here’s the URL:
https://api.freecodecamp.org/internal/api/users/get-public-profile?username=myUsername

It works just fine in the browser (I see all my data pop up), but a curl in terminal shows the 502. Any ideas what’s going on?

I have encountered the same problem, so it would be great to get an official answer for the change.

In the meantime, a work-around is to add headers to your request to pretend that you’re a web browser.
I’m using Axios to make the request, so in my case this looked like:

  // Fetch the user profile from FCC.
  const url = 'https://api.freecodecamp.org/api/users/get-public-profile?username=SOME-USERNAME-HERE';

  // Add headers as a browser, to avoid 502 response.
  let headersConfig = {
    headers: {
      'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36"
    }
  }

  const ret = await axios.get(url, headersConfig);

With the above I get the correct response, as in the past.
I also tried using a user agent particular to my app, but this request fails, it looks like the API is looking for actual browser details.

Have the terms of use of the API changed? Are we not meant to access it programmatically any more?

I don’t know if the API changed but this happened recently, so it’d guess there is more security:

tldr; API was exploited to make false donations to verify credit card info