You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Got multiple apps working on one server successfully, why no official support? #1979
Like most of Parse.com users, I've got multiple applications running in my Parse account. So I was curious to know if there is any way to do this on a self-hosted parse server or not. After trying different approaches (even running independent server per application, which is a crazy idea!) this is my final configuration which make me able to run multiple applications on one parse server:
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var first = new ParseServer({
databaseURI: ' ,.',
appId: ' ,.',
masterKey: ' ,.',
serverURL: 'http://localhost:1400/parse',
cloud: 'cloud/first.js'
});
var second = new ParseServer({
databaseURI: ' ,.',
appId: ' ,.',
masterKey: ' ,.',
serverURL: 'http://localhost:1400/parse',
cloud: 'cloud/second.js'
});
var app = express();
app.use('/parse', first);
app.use('/parse', second);
var port = 1400;
var httpServer = require('http').createServer(app);
httpServer.listen(port, 'localhost');
With this configuration inside index.js file, I was able to make both application running on https://mydomain.com/parse and each could be authorized using their own appId and masterKey. Even Cloud Code for each application is working without any problem.
The point is that, why this ability isn't officially documented? Parse developers are saying that running multiple applications on same server isn't supported (Even when I want to run parse-server with terminal command and a configuration for multiple applications, I get an error saying running multiple applications isn't supported). But as I said, I was able to this by editing index.js file in source code like above.
All of these things make me think that I'm missing something. Am I?!
Concurrent cloud code requests will affect the Parse js SDK and the applicationId won't match.
There is a big chance that all cloud code requests for your first app will end up affecting your second. So yes, that works only if you don't use cloud code
This issue is asynchronous Cloud Code. The issues will only show up when a) both apps are receiving requests at the same time, and b) your Cloud Code does asynchronous stuff like making queries or writes.
Oh, now I see. I'd experienced an interesting issue while configuring parse server in my way. Whenever I didn't set serverURL for one of applications, other applications couldn't send requests to their own databases either! (which logically is odd. because one application may use Cloud Code and other may not). So Cloud Code gets broken is some way with this configuration.
Thank you @flovilmart and @drew-gross for pointing this out. Since hosting multiple applications is more important than using Cloud Code for me, I will abandon Cloud Code for now, and use PHP requests to simulate Cloud Code functionality in my applications.
I missed a little thing. The problem you said about Cloud Code, is it because of using one server for all applications, or sharing /parse as mount path? I mean, can this problem be solved by using exclusive mount path for each application?
As @flovilmart said, problem is inside Parse JS SDK and I think it has nothing to do with mount path. But I want to make sure.
@flovilmart@drew-gross My cloud code is running. The only problem seems to be that the internal serverURL is shared so that requests to the cloud API go to the same URL. Can you point me to the singleton object. I'd like to attempt to fix this.
the whole JS SDK is a singleton, probably other parts of parse-server don't play well with multiple apps.
The only problem seems to be
That's not the only problem, also your appId, jsKey, context, variables. if another request comes in when processing the previous one from another app, your whole context would get f...d up.
Activity
flovilmart commentedon Jun 2, 2016
Concurrent cloud code requests will affect the Parse js SDK and the applicationId won't match.
There is a big chance that all cloud code requests for your first app will end up affecting your second. So yes, that works only if you don't use cloud code
drew-gross commentedon Jun 2, 2016
This issue is asynchronous Cloud Code. The issues will only show up when a) both apps are receiving requests at the same time, and b) your Cloud Code does asynchronous stuff like making queries or writes.
ahmadhashemi commentedon Jun 2, 2016
Oh, now I see. I'd experienced an interesting issue while configuring parse server in my way. Whenever I didn't set serverURL for one of applications, other applications couldn't send requests to their own databases either! (which logically is odd. because one application may use Cloud Code and other may not). So Cloud Code gets broken is some way with this configuration.
Thank you @flovilmart and @drew-gross for pointing this out. Since hosting multiple applications is more important than using Cloud Code for me, I will abandon Cloud Code for now, and use PHP requests to simulate Cloud Code functionality in my applications.
drew-gross commentedon Jun 2, 2016
You could also run multiple parse servers in multiple processes, on different subdomains or ports.
ahmadhashemi commentedon Jun 4, 2016
I missed a little thing. The problem you said about Cloud Code, is it because of using one server for all applications, or sharing /parse as mount path? I mean, can this problem be solved by using exclusive mount path for each application?
As @flovilmart said, problem is inside Parse JS SDK and I think it has nothing to do with mount path. But I want to make sure.
flovilmart commentedon Jun 4, 2016
The JSSDK is a global object, you will encounter problems with your cloud code as soon as you have concurrent calls on your apps.
jkassis commentedon Feb 12, 2017
@flovilmart @drew-gross My cloud code is running. The only problem seems to be that the internal serverURL is shared so that requests to the cloud API go to the same URL. Can you point me to the singleton object. I'd like to attempt to fix this.
flovilmart commentedon Feb 12, 2017
the whole JS SDK is a singleton, probably other parts of parse-server don't play well with multiple apps.
That's not the only problem, also your appId, jsKey, context, variables. if another request comes in when processing the previous one from another app, your whole context would get f...d up.
If you're unsure, please read: #263
and particularly: #263 (comment)