From a65f2d13abdc9d4663d61308f426dd517491c9ee Mon Sep 17 00:00:00 2001 From: Andrew Mihailov Date: Mon, 1 Feb 2016 19:23:05 +0200 Subject: [PATCH] Added ability to set server url for Parse JS client SDK whithin ParseServer constructor --- README.md | 7 +++++-- index.js | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 700d675475..a08a38e1db 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ There is a development wiki here on GitHub: https://github.com/ParsePlatform/par * cloud - The absolute path to your cloud code main.js file * fileKey - For migrated apps, this is necessary to provide access to files already hosted on Parse. * facebookAppIds - An array of valid Facebook application IDs. +* serverURL - URL which will be used by Cloud Code functions to make requests against. #### Client key options: @@ -45,6 +46,8 @@ var ParseServer = require('parse-server').ParseServer; var app = express(); +var port = process.env.PORT || 1337; + // Specify the connection string for your mongodb database // and the location to your Parse cloud code var api = new ParseServer({ @@ -52,7 +55,8 @@ var api = new ParseServer({ cloud: '/home/myApp/cloud/main.js', // Provide an absolute path appId: 'myAppId', masterKey: 'mySecretMasterKey', - fileKey: 'optionalFileKey' + fileKey: 'optionalFileKey', + serverURL: 'http://localhost:' + port + '/parse' // Don't forget to change to https if needed }); // Serve the Parse API on the /parse URL prefix @@ -63,7 +67,6 @@ app.get('/', function(req, res) { res.status(200).send('Express is running here.'); }); -var port = process.env.PORT || 1337; app.listen(port, function() { console.log('parse-server-example running on port ' + port + '.'); }); diff --git a/index.js b/index.js index 79a321986f..c7631b08c2 100644 --- a/index.js +++ b/index.js @@ -72,6 +72,9 @@ function ParseServer(args) { // Initialize the node client SDK automatically Parse.initialize(args.appId, args.javascriptKey || '', args.masterKey); + if(args.serverURL) { + Parse.serverURL = args.serverURL; + } // This app serves the Parse API directly. // It's the equivalent of https://api.parse.com/1 in the hosted Parse API.