Skip to content

Can I connect client to multiple parse servers? #5829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DuanYH16 opened this issue Jul 19, 2019 · 1 comment
Closed

Can I connect client to multiple parse servers? #5829

DuanYH16 opened this issue Jul 19, 2019 · 1 comment

Comments

@DuanYH16
Copy link

I am trying to connect different react components in the same app to multiple parse servers but I can only connect to one parse server.

App.js is the parent component and App2.js is the child component.

I have started 2 parse servers, each running on different ports.

Parse server A runs on port 1330, 1331 (livequery) while the other server B runs on port 1337, 1338 (livequery). I tried to connect App.js to A and App2.js to B but App2.js still connects to A.

Is it possible to connect App2.js to both server A and B?

in App.js:

import { Parse as UserParse } from "parse";
UserParse.initialize("APP_ID");
UserParse.serverURL = "http://localhost:1330/parse";
UserParse.liveQueryServerURL = "ws://localhost:1331/";

in App2.js:

import {Parse as DataParse } from "parse";
DataParse.initialize("APPLICATION_ID")
DataParse.serverURL = "http://localhost:1337/parse"
DataParse.liveQueryServerURL = "ws://localhost:1338/"
Errors encountered:

RESTController.js:205 POST http://localhost:1337/parse/classes/400 (Bad Request)

Uncaught (in promise) Error: Invalid session token at RESTController.js:319

@davimacedo
Copy link
Member

Unfortunately you can't do that using the JS SDK. The JS SDK does not support multiple apps,ince some of its methods (for instance, the Parse.initialize()) are static. So any change in the initialization will affect the SDK globally.

If you need to connect to different apps from the client side, you will have to use the REST API or the GraphQL API directly, without using the JS SDK (or using the SDK for one app and one of the APIs for the other app).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants