Deploying your SSR app to Zeit Now from GoDaddy

Alessandro Giordo
6 min readApr 20, 2018

--

We recently rebuilt our old AngularJS (1.5) app using Nuxt.js and WordPress REST API for better SSR and an opinionated folder and pattern structure.

If you are interested in that article, you can read it here:
https://medium.com/@moustachedesign/creating-a-website-with-nuxt-js-and-wordpress-rest-api-51cf66599cf3

We have a Backend Developer specialising in Laravel and PHP, and our servers are with a traditional PHP Server (you guess it), so deploying an app with Node.js is not exactly the easiest thing to do.

Enter, NOW

You might know Zeit for the very similar Next used by my fellow React developers, or for Hyper terminal (an Electron based terminal that looks cool).

They’ve been around their fair share of time and I had no objections from the CEO to go for them when looking for a stable production environment.
They offer out of the box CDN, DNS optimizations and all sorts of things you expect from a top-level hosting provider.

Their major advantage is being a kind of “serverless” infrastructure for your Node.js app (and others).
They provide a CLI (now-cli) which allows you to manage your deployments, instances, DNS, aliases and so on with it.

The documentation is quite exhaustive and gives you a very handy 100% uptime Migration guide that helps you migrate your domain and hosting to them without losing a single minute of uptime.

Then, you have a domain on GoDaddy and… it’s not that simple anymore.

You see.., to preserve uptime now makes you externally add the domain, then you can add a certificate for it, DNS zone records from the current registrar, and then an alias that allows you to keep your DNS intact while migrating the app.
The problem is the ALIAS — ANAME.

If you have an apex domain like ours (antilophia.com), you need an ANAME or ALIAS record to be added in your current registrar to make this work.

GoDaddy doesn’t have ANAME or ALIAS records… Why?!

GoDaddy, if you are reading this… do something about this! K, thx.

Fret not, there’s a way to solve this guys. I just did (thanks, Tim from Zeit for the help so far).
I’m a good guy, I’ll show ya’ll how to do the same if you have a domain with GoDaddy.

Preparation and Migration

  1. Deploy to Now
  2. Adding Your Domain
  3. Upload SSL Certificates
  4. Update DNS Records

After you install now-cli, login to your account with now login then navigate to your folder and create a file called now.json .
This will include the name of your app and the alias (or aliases) you want to setup.

{  "name": "app-name",  "alias": [    "staging.yourdomain.com",    "yourdomain.com"  ]}

As you can see, we create an instance called antilophia (the ID) and point to an alias for staging and another for production.

We are more interested in the production one (for staging, we’ll come back to it later, but in the meantime you can always CNAME your regular domain to point to alias.zeit.co if you want to deploy to your subdomain.domain.com)

Then create an npm script to deploy your app with this file we just created

"scripts": {    ...    "staging": "now && now alias antilophia-vue.nakedtesting.com",    "production": "now && now alias",
...
},

This will allow you to deploy your staging or production env by just typing

npm run staging or npm run production

Simple as that.

We will deploy just typing nowinside your project folder (make sure you have a build and start script inside your package.json)

You would normally add an external domain, then add certs and so on but with GoDaddy it’s not that simple (or it is, if you follow this guide)

now domains add yourdomain.com --external --force

This adds the domain so that now knows you will add this later.

Then type now alias yourdomain.com so that you have the alias ready when you switch nameservers

You might get a message like:

> Error! Verification required: Please add the following TXT record on the external DNS server: _now.example.ai: b0981886d2c312e35c6b311cddd4eb0aea2e71a97d1e068b25f569527880f1bd

So all you need to do is add a TXT record to GoDaddy for your domain with _now as name and value of that hash above.

Run now domains add yourdomain.com --force again to validate this.

We need now to get some certs going for the move.
You can then add Let’s Encrypt later for auto renewal, or use your own certs if you are that kind of guy.

Locate your .key, .crt and CA file for your cert and either download them or install now where they are (login as well you dummy).

Once in that folder all you need to do is type:

now certs add --key yourdomain.com.key --crt yourdomain.com.crt --ca ssl_provider.crt

This will install that certificate for your domain.

> Success! Certificate entry yourdomain.com (vDKECujW1pNt8O2HbWXp) created [598ms]

Now comes the annoying bit.
Step 4 in the migration guide can’t be done. Simple as that.

There’s no ANAME or ALIAS on GoDaddy, so we will need to skip to the DNS records setup.
Go to your GoDaddy domain → manage DNS

You will have a list of DNS records you setup for yourdomain.com.
You can decide to export this to copy-paste.

Be careful not to add records that are related to GoDaddy (_custom* or similar).

to add a DNS record on now, you just type:
now dns add <domain> <name> <record type> <value> [mx_priority]

now dns add <domain> <name> <record type> <value> [mx_priority]

example:

now dns add yourdomain.com www CNAME yourdomain.com --force

now dns add yourdomain.com @ MX some.mx.record --force

With CNAME in particular, if on GoDaddy you have @ as value, you need to specify the domain itself like above.
The rest of the commands are self explanatory.

Once you have these setup we will need to migrate nameservers to zeit ones.
You have a list of nameservers here https://zeit.co/world#get-started

Once that’s done, we need to alias the domain to the current deployment we run before with now

Just type now dns add yourdomain.com — forceto add the domain as internal and the latest deployment will be aliased to yourdomain.com.

If you get an error (unable to verify) it means your nameserver change hasn’t propagated yet.
You can speed this up clearing your dns cache or changing your network DNS (go to 8.8.8.8 and search for yourdomain.com if you are on mac, or if you have google already, try switching to cloudflare)
I think this sped up my DNS cache clear for me.

Once you have aliased it, the new site should be up for you.
You can visit the one we just deployed at https://antilophia.com or contact us at https://nakedideas.com for consultancy and gifs.

cat says thanks

I hope this guide was useful for you if you are trying to migrate a domain from GoDaddy and use Zeit now services.

If you liked it,

Smash that applause button to 50 or beyond!

--

--

Alessandro Giordo

Cycling Advocate and YouTuber / Software Engineer at Vodafone UK / Check out my stories and YouTube channel 🔗 https://youtube.com/TheBikeChallenge