Google cloud function for GoDaddy queries. To be used in conjunction with Name Hacker
All this function does is to query the GoDaddy for domain availability. GoDaddy requires an Authorization key to make this query hence I made this cloud function to keep the key private. Also GoDaddy servers have CORS disabled so anyways you can't make this query from a proper browser. Although meant to be deployed as a Google Cloud Function you can easily port the code to run on an Express server with minimal changes.
- Register at GoDaddy Developer and create an API key
- Clone this repository
- Create a
.env
file in the root of the repository and add the following entryGODADDY_API_KEY=<your API key>
Check this tutorial for a step-by-step guide to writing and deploying cloud functions. Here I'll quickly walk you through the steps:
- Register for Google Cloud
- Create a new project and enable Cloud-Functions + Billing
- Install and initialize the Google Cloud SDK
- Install
gloud
Beta components - Create a Cloud Storage Bucket to host the function. Note the name.
- Navigate to the root of the cloned repository and run the following command:
gcloud beta functions deploy godaddyProxy --stage-bucket <your bucket name> --trigger-http
- The function will be deployed and the corresponding URL will be shown on the terminal
You can use cURL to make a query to the endpoint:
curl <cloud-url>?domain=terriblenames.com
You will get a json response like (the same response returned from GoDaddy):
{"available":true,"domain":"terriblenames.com","definitive":false,"price":7490000,"currency":"USD","period":1}
If you want to restrict calls to this function from a specific domain (browser only) you can set the following in the .env
file:
ALLOWED_DOMAIN=https://mysite.com
This will basically set the Access-Control-Allow-Origin
header to your domain