now-url-hub v0.1.0
now-url-hub
A little devops module that helps you figure out and access your OSS now deployment urls.
Use case
You are deploying on now under the OSS plan. You serve a frontend that does reconnect to your backend, for establishing websockets or similar. Without server side rendering, how do you know your server's address? -> now-url-hub.
Usage
When deploying your server on now you need to run this module's cli in order to post your deployment url under an alias. That way, the now-url-hub server always has the latest deployment url:
Run
now secrets add now_url_hub_password <YO PASSWORD>from a terminal. The password is used to ensure that only you can update the url an alias points to.When running
nowor insidenow.jsonpass yo password on as environment variable:
{
...,
"env": {
"NOW_URL_HUB_PASSWORD": "@now_url_hub_password"
}
}- Run the
now-url-hubcli with no arguments (for convenience). If you have anpmtype deployment usenpm's prestart script for that. If using docker just RUN the cli with the required environment variableNOW_URL_HUB_PASSWORDin place.
Accessing a mapping is a simple get from https://now-url-hub-ipmtcknuik.now.sh/alias/${YO_ALIAS}; returns JSON like:
{
"alias": "yo_alias",
"url": "yo_alias-ipmtcknuik.now.sh"
}Get it!
npm install --save now-url-hub