Skip to content

Instantly share code, notes, and snippets.

@spences10
Last active May 14, 2017 20:56
Show Gist options
  • Save spences10/da228debe28635db8cb2574e35d81c91 to your computer and use it in GitHub Desktop.
Save spences10/da228debe28635db8cb2574e35d81c91 to your computer and use it in GitHub Desktop.

Alias your site to your domain

now alias my-api-xyz.now.sh my-new-domain.com

Alias your site to custom name

now alias my-api-xyz.now.sh my-new-custom-name

To remove alias

now alias rm 

Securing Env Variables Using Secrets

List all your secrets:

now secrets ls

Add a new secret:

now secrets add my-secret "my value"

Once added, a secret's value can't be retrieved in plaintext anymore If the secret's value is more than one word, wrap it in quotes Actually, when in doubt, wrap your value in quotes

Expose a secret as an env variable:

now -e MY_SECRET=@my-secret

Notice the @ symbol which makes the value a secret reference.

Rename a secret:

now secrets rename my-secret my-renamed-secret

Remove a secret:

now secrets rm my-secret

Once you have created your secrets you can then use them in an npm script as part of your package.json:

"scripts": {
  "start": "node index.js",
  "deploy": "now -e CONSUMER_KEY=@consumerkey -e CONSUMER_SECRET=@consumersecret"
},

This is assuming you have two secrets configured called consumerkey and consumersecret

Include files

If you have files ignored with .gitignore which you want to add to now you will need to include them in your package.json with the now setting:

 "now": {
    "alias": "alias-name",
    "files": [
      "src",
      "index.js"
    ]
  },

You will also need to define in the .npmignore what you want including in the build, so say you want to include a *.csv files then:

!*.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment