Skip to content

Commit a65f2d1

Browse files
committed
Added ability to set server url for Parse JS client SDK whithin ParseServer constructor
1 parent 25a0fbe commit a65f2d1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ There is a development wiki here on GitHub: https://github.com/ParsePlatform/par
1818
* cloud - The absolute path to your cloud code main.js file
1919
* fileKey - For migrated apps, this is necessary to provide access to files already hosted on Parse.
2020
* facebookAppIds - An array of valid Facebook application IDs.
21+
* serverURL - URL which will be used by Cloud Code functions to make requests against.
2122

2223
#### Client key options:
2324

@@ -45,14 +46,17 @@ var ParseServer = require('parse-server').ParseServer;
4546

4647
var app = express();
4748

49+
var port = process.env.PORT || 1337;
50+
4851
// Specify the connection string for your mongodb database
4952
// and the location to your Parse cloud code
5053
var api = new ParseServer({
5154
databaseURI: 'mongodb://localhost:27017/dev',
5255
cloud: '/home/myApp/cloud/main.js', // Provide an absolute path
5356
appId: 'myAppId',
5457
masterKey: 'mySecretMasterKey',
55-
fileKey: 'optionalFileKey'
58+
fileKey: 'optionalFileKey',
59+
serverURL: 'http://localhost:' + port + '/parse' // Don't forget to change to https if needed
5660
});
5761

5862
// Serve the Parse API on the /parse URL prefix
@@ -63,7 +67,6 @@ app.get('/', function(req, res) {
6367
res.status(200).send('Express is running here.');
6468
});
6569

66-
var port = process.env.PORT || 1337;
6770
app.listen(port, function() {
6871
console.log('parse-server-example running on port ' + port + '.');
6972
});

index.js

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ function ParseServer(args) {
7272

7373
// Initialize the node client SDK automatically
7474
Parse.initialize(args.appId, args.javascriptKey || '', args.masterKey);
75+
if(args.serverURL) {
76+
Parse.serverURL = args.serverURL;
77+
}
7578

7679
// This app serves the Parse API directly.
7780
// It's the equivalent of https://api.parse.com/1 in the hosted Parse API.

0 commit comments

Comments
 (0)