HTTP request is not the same on Heroku and Google Cloud Run

I have a NodeJS/ExpressJS API that performs an HTTP request to get some JSON before sending a response. Here’s the snippet of code:

const ipApiUrl = `https://ipapi.co/${ip}/json/`
const ipApiResponse = await axios.get(ipApiUrl)
console.log(ipApiResponse.data)
ipCountryCode = ipApiResponse.data.country_code

This code works fine locally. It also works fine on Heroku. However, it does NOT work the same on Google Cloud Run.

Here’s what ipApiResponse.data should be:

{
    "ip": "141.117.117.76",
    "city": "Toronto",
    "region": "Ontario",
    "region_code": "ON",
    "country": "CA",
    "country_code": "CA",
    ...
}

HOWEVER, when sending the request from Google Cloud Run the API I’m using returns something different. Instead I get this response:

{ ip: '169.254.8.129', reserved: true }

I think this problem is with either Google Cloud Run or Docker because I also have issues with making HTTP requests to other sites, like ipstack.com.

I am deploying to Google Cloud Run by using Docker. My Dockerfile is using node:10 and exposes the PORT environment variable like the documentation says. Everything else works fine except for this HTTP request. I’ve tried both axios and fetch.

Source: StackOverflow