Skip to content

Commit 27560e1

Browse files
committed
Merge pull request #132 from r4zzz4k/master
Added ability to set server url for Parse JS client SDK
2 parents 4b1132a + a65f2d1 commit 27560e1

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
@@ -22,6 +22,7 @@ There is a development wiki here on GitHub: https://github.com/ParsePlatform/par
2222
* cloud - The absolute path to your cloud code main.js file
2323
* fileKey - For migrated apps, this is necessary to provide access to files already hosted on Parse.
2424
* facebookAppIds - An array of valid Facebook application IDs.
25+
* serverURL - URL which will be used by Cloud Code functions to make requests against.
2526

2627
#### Client key options:
2728

@@ -49,14 +50,17 @@ var ParseServer = require('parse-server').ParseServer;
4950

5051
var app = express();
5152

53+
var port = process.env.PORT || 1337;
54+
5255
// Specify the connection string for your mongodb database
5356
// and the location to your Parse cloud code
5457
var api = new ParseServer({
5558
databaseURI: 'mongodb://localhost:27017/dev',
5659
cloud: '/home/myApp/cloud/main.js', // Provide an absolute path
5760
appId: 'myAppId',
5861
masterKey: 'mySecretMasterKey',
59-
fileKey: 'optionalFileKey'
62+
fileKey: 'optionalFileKey',
63+
serverURL: 'http://localhost:' + port + '/parse' // Don't forget to change to https if needed
6064
});
6165

6266
// Serve the Parse API on the /parse URL prefix
@@ -67,7 +71,6 @@ app.get('/', function(req, res) {
6771
res.status(200).send('Express is running here.');
6872
});
6973

70-
var port = process.env.PORT || 1337;
7174
app.listen(port, function() {
7275
console.log('parse-server-example running on port ' + port + '.');
7376
});

index.js

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

8383
// Initialize the node client SDK automatically
8484
Parse.initialize(args.appId, args.javascriptKey || '', args.masterKey);
85+
if(args.serverURL) {
86+
Parse.serverURL = args.serverURL;
87+
}
8588

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

0 commit comments

Comments
 (0)