Unable to connect to mLab database from self-hosted Parse

孤人 提交于 2019-12-13 07:28:16

问题


TL;DR: I can get my parse dashboard talking to my locally-hosted Parse server and mongo db instance but cannot get the parse server to talk to the mLab-hosted database.

I am going through the Parse migration guide and have got mongo DB, parse-server-example and parse-dashboard running locally. When I use the following details in the parse index.js file I can successfully connect the dashboard and see the test items in the database:

databaseURI: 'mongodb://localhost:27017/dev',
cloud: __dirname + '/cloud/main.js',
appId: '1',
masterKey: '1',
serverURL: 'http://localhost:1337/parse'

I have installed mongo db locally and when connecting to my mLab instance with the shell I can see the database content. When I use that same mLab connection string in the databaseURI parameter within index.js the dashboard can no longer see the database content and the /test page on the locally-hosted parse server.

The Parse Migration Guide states...

Go to the Security & Keys section of App Settings in your Dashboard and take note of the File Key and Master Key values. Pass that into the ParseServer constructor in index.js. You no longer need to use a client key with Parse Server.

I can find those keys but I cannot see where to put the File Key into the index.js.

I also do not understand why those keys are required if the locally-hosted Parse server and mLab database know nothing about them.


回答1:


steps :

create your user/pwd in the mLab/mongo instance

get the db URL from mLab dashboard

connect using a command lib client to verify what parse-server will use. this verifies the user/pwd you will use below...

go back to 'parse-server.js' to config it for mongo/remote

var databaseUri = $what-was-on-cli-client-above

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://<db.....

  .... 


来源:https://stackoverflow.com/questions/41180646/unable-to-connect-to-mlab-database-from-self-hosted-parse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!