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?