I have created an api using AWS API Gateway and would like to attach a custom domain name to it. I followed this tutorial and have done the following:
- Created new certificate on Certificate Manager (
mydomain.ioand*.mydomain.io) - Added CNAME to GoDaddy (since mine was purchased from Godaddy)
- Set up a
api-dev.mydomain.ioon API gateway > Custom domain names, and mapped it to the API and dev stage in the "API Mappings". - On Route 53, added
api-dev.mydomain.ioas an A record and direct it to the API (the API domain name is correct) in step 3.
I believe that my setup should be correct to the best of my knowledge, and have waited 1 hour for it to "take effect".
I then write a simple script to test it but it throws the above error.
Code:
const axios = require("axios")
let baseUrl = "https://api-dev.mydomain.io"
let key = MY_API_KEY
let headers = {
headers: {
"x-api-key": key
}
}
let usersEndpoint = baseUrl + '/token?email=someemail@gmail.com'
axios.get(usersEndpoint, headers)
.then(response => {
let data = response.data
console.log(data)
})
.catch(err => console.log(err))
Error message:
Error: getaddrinfo ENOTFOUND api-dev.mydomain.io
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26) {
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'api-dev.mydomain.io',
config: {
url: 'https://api-dev.mydomain.io/token?email=someemail@gmail.com',
method: 'get',
headers: {
Accept: 'application/json, text/plain, */*',
'x-api-key': MY_API_KEY,
'User-Agent': 'axios/0.21.1'
},
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
adapter: [Function: httpAdapter],
...
What am I missing?