Skip to content

Latest commit

 

History

History
70 lines (42 loc) · 2.93 KB

deploy.md

File metadata and controls

70 lines (42 loc) · 2.93 KB

Deploy your custom API in the cloud

This guide will walk you through the process of deploying your custom API in the cloud. You will use Render, a Platform-as-a-Service cloud, to run your application.

⚠ When working as a team, only one member of the team needs to follow this guide.

Requirements

Create your Render account

Register a Render account if you haven't already. If you register through GitHub, you will not have to link the two accounts together later.

Render: register using an exisiting GitHub Account

Go to your dashboard and create a new Web Service:

Render: dashboard

Connect your GitHub repository to Render by selecting the one the contains your app from the list.

Render: connect to repo

Name the application as you wish, choose the region and enter the commands used to build and start your app. The branch name should automatically be set to "main" or "master", depending on how your repository is setup.

Render: setup your application

Next, click the "Advanced" button to set up the required environment variables.

Render: setup your environment variables

You'll need to create three environment variables:

Name Value
SECRET Any string value. You can let Render generate a random value for you by clicking the "Generate" button
DATABASE_URL The connection string for your database user. You should have or will soon receive it
DATABASE_NAME The name of the database for your API. You should have or will soon receive it
CORS true - Wether your API can be requested by an app hosted on another domain

Render: create your environment variables

Once you submit the form, Render will automatically try to deploy your app. You will be able to see live logs. Pretty cool, but be aware that deploys on the free plan can take a little while. Be patient.

Render: first deploy

Once your deploy is live, you should be able to test your API at the URL generated by Render. It should look something like: https://<your-app-name>.onrender.com

Render: find your app URL

Navigating to this URL will display your API doc.

Note that the URL in the examples might not match the actual URL of your deployed API.

Be careful if you copy/paste (which you probably will. I know you will).

You can test that everything is OK by going to https://<your-app-name>.onrender.com/api/users which should only display an empty json array.

🎉