将应用程序连接到 Heroku 上的 ParseServer

Connecting app to ParseServer on Heroku

我正在学习这些教程: http://rogerstringer.com/2016/02/04/parse-server-heroku/ https://devcenter.heroku.com/articles/deploying-a-parse-server-to-heroku

我正在尝试将 ParseServer 部署到 Heroku 并将我的应用程序与其连接。 部署部分进行得很好,我可以看到这个: 'I dream of being a web site.'

我不知道把clientId 和appId 放在哪里。 这些是我在 Heroku 部分的配置变量:

这是我在 github:

上的 ParseServer 中的代码
var api = new ParseServer({
    databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
    cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
    appId: process.env.APP_ID || 'reciparia',
    masterKey: process.env.MASTER_KEY || '' //Add your master key here. Keep it secret!
});

AppDelegate 中的代码:

   let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
  ParseMutableClientConfiguration.applicationId = "reciparia"
  ParseMutableClientConfiguration.clientKey = "CLIENT_KEY"
  ParseMutableClientConfiguration.server = "https://amazing-parse.herokuapp.com/parse"
})

因为在 ParseClientConfiguration 上必须有一个 clientKey,我应该在 ParseServer 上有一个。

我应该把它放在哪里?来自 Heroku UI 的配置变量,或来自 ParseServer 的 index.js?

相同的 clientKey 需要在 ParseServer(位于 index.js)和 AppDelegate.swift(在客户端)上。

我从 ParseServer 添加了 clientKeyindex.js。还需要在两侧找到变量 appId

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'reciparia',
  masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
  clientKey: process.env.CLIENT_KEY || 'holla'
});

AppDelegate.swift,保持不变:

  let parseConfiguration = ParseClientConfiguration(block: {   (ParseMutableClientConfiguration) -> Void in
     ParseMutableClientConfiguration.applicationId = "reciparia"
     ParseMutableClientConfiguration.clientKey = "holla"
     ParseMutableClientConfiguration.server = "https://amazing-parse.herokuapp.com/parse"
  })

我还稍微修改了配置变量,因为这里也有相同的 CLIENT_KEY 和 APP_ID。我发现现在只修改配置变量和 AppDelegate 更方便,因为我的凭据现在是 public :)。