【问题标题】:Connecting app to ParseServer on Heroku将应用程序连接到 Heroku 上的 ParseServer
【发布时间】:2016-02-16 10:02:15
【问题描述】:

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

我正在尝试将 ParseServer 部署到 Heroku 并将我的应用程序与它连接。 部署部分进展顺利,我可以看到这个: '我梦想成为一个网站。'

我不知道把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 的 Config Vars 或 ParseServer 的 index.js 上?

【问题讨论】:

    标签: swift heroku parse-server


    【解决方案1】:

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

    我从 ParseServer 将 clientKey 添加到 index.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 更方便,因为我的凭据现在是公开的 :)。

    【讨论】:

      猜你喜欢
      • 2021-03-05
      • 2016-01-24
      • 2013-11-30
      • 1970-01-01
      • 2014-07-09
      • 2020-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多