Deploying a Parse Server to Heroku
Last updated May 15, 2024
Table of Contents
Parse Server is a Parse API compatible Express router package and an alternative to the discontinued hosted Parse service.
This guide shows you how to deploy and configure a Parse server on Heroku. A Heroku account is required, sign-up for free.
Source for this article’s reference application is available on GitHub. You can deploy the reference application using the Heroku Button below.
Create an app
To create a new app, visit the Heroku Dashboard and select Create new app
from the drop-down menu.
Install a MongoDB add-on
Click the Resources
tab, then select and install the MongoLab add-on.
Connect to GitHub
Before connecting the parse-server-example
to your Heroku app, fork the official example.
To connect the parse-server-example
to your Heroku app, you must enable the GitHub integration, and connect the app to the parse-server-example
repo.
When the connection is established, the dashboard will update.
Deploy
Trigger a manual deployment of the main branch.
Once the build is complete, click view
to open the app in a new browser tab.
If the parse-server-example
has been successfully deployed, you will now see, “I dream of being a web site.”
You can now use the standard REST interface, JavaScript SDK, and any of the Parse open-source SDKs.
$ curl -X POST \
-H "X-Parse-Application-Id: myAppId" \
-H "Content-Type: application/json" \
-d '{}' \
https://example-app-1234567890ab.herokuapp.com/parse/functions/hello
..
{"result":"Hi"}%
Configuring your Parse server with config vars
The Parse server is configured during instantiation. The index.js
file in the parse-server-example
specifies defaults, which are superseded by config vars, made available to our application via environment variables.
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || 'myMasterKey'
});
var app = express();
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
You can edit config vars from Settings
tab in Dashboard: